express config

This commit is contained in:
2022-05-30 14:11:13 -05:00
parent 832620fa68
commit 8e9fd6433d
7 changed files with 36 additions and 17 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,5 @@
node_modules/
.DS_Store
.env
config.env

View File

@@ -1,6 +1,6 @@
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { useContext, useReducer } from 'react';
import { appState, initialState, reducer, AppContext } from './store/store';
import { useContext } from 'react';
import { AppContext } from './store/store';
import NavBar from './components/Navbar';
import LandingPage from './components/LandingPage';
@@ -11,7 +11,6 @@ import Register from './components/User/Register';
import './App.scss'
function App() {
const [state, dispatch] = useReducer(reducer, initialState);
const context = useContext(AppContext);
return (

View File

@@ -3,11 +3,11 @@ import { userInfo, Cart, } from "../types/main";
// type definitions for reducer
export enum ActionType {
GETALL = 'GETALL',
GETONE = 'GETONE',
REGISTERNEW = 'REGISTERNEW',
UPDATEONE = 'UPDATEONE',
SEARCH = 'SEARCH',
GETALL,
GETCATEGORY,
REGISTERNEW,
UPDATEONE,
SEARCH,
}
export interface userAction {
@@ -46,7 +46,7 @@ export const reducer = (state: appState, action: userAction) => {
switch (type) {
case ActionType.GETALL:
return state;
case ActionType.GETONE:
case ActionType.GETCATEGORY:
return state;
case ActionType.REGISTERNEW:
return state;

View File

@@ -1,2 +0,0 @@
PORT=8088
CONNECTION=postgres://mikayladobson@localhost/ecommerce_041822

14
package-lock.json generated
View File

@@ -14,6 +14,7 @@
"cors": "^2.8.5",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"helmet": "^5.1.0",
"oauth2-server": "^3.1.1",
"passport": "^0.6.0",
"passport-local": "^1.0.0",
@@ -651,6 +652,14 @@
"resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz",
"integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk="
},
"node_modules/helmet": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/helmet/-/helmet-5.1.0.tgz",
"integrity": "sha512-klsunXs8rgNSZoaUrNeuCiWUxyc+wzucnEnFejUg3/A+CaF589k9qepLZZ1Jehnzig7YbD4hEuscGXuBY3fq+g==",
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/http-errors": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
@@ -2071,6 +2080,11 @@
"resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz",
"integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk="
},
"helmet": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/helmet/-/helmet-5.1.0.tgz",
"integrity": "sha512-klsunXs8rgNSZoaUrNeuCiWUxyc+wzucnEnFejUg3/A+CaF589k9qepLZZ1Jehnzig7YbD4hEuscGXuBY3fq+g=="
},
"http-errors": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",

View File

@@ -15,6 +15,7 @@
"cors": "^2.8.5",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"helmet": "^5.1.0",
"oauth2-server": "^3.1.1",
"passport": "^0.6.0",
"passport-local": "^1.0.0",

View File

@@ -1,21 +1,25 @@
const express = require('express');
const cors = require('cors');
const app = express();
const bodyParser = require('body-parser');
const apiRouter = require('./routes/API');
const session = require('express-session');
require('dotenv').config({ path: './config.env' });
const PORT = process.env.PORT;
app.use(cors());
app.use(express.json());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
app.use(express.urlencoded({
extended: true
}));
app.use(session({
secret: 'secret',
cookie: { maxAge: 300000000, secure: false }
}))
const apiRouter = require('./routes/API');
app.use(apiRouter);
app.listen(PORT, () => {