adding basic user controller and model as well as updating user route
This commit is contained in:
10
api/app.js
10
api/app.js
@@ -1,10 +1,12 @@
|
||||
|
||||
import cookieParser from 'cookie-parser';
|
||||
import cors from 'cors';
|
||||
import express from 'express';
|
||||
import createError from 'http-errors';
|
||||
import logger from 'morgan';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import xss from 'xss-clean';
|
||||
|
||||
import indexRouter from './routes/index.js';
|
||||
import usersRouter from './routes/users.js';
|
||||
@@ -18,14 +20,20 @@ const app = express();
|
||||
app.set('views', path.join(__dirname, 'views'));
|
||||
app.set('view engine', 'jade');
|
||||
|
||||
app.use(cors());
|
||||
app.options('*', cors());
|
||||
|
||||
app.use(logger('dev'));
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: false }));
|
||||
app.use(cookieParser());
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
// Data sanitization against XSS
|
||||
app.use(xss());
|
||||
|
||||
app.use('/', indexRouter);
|
||||
app.use('/users', usersRouter);
|
||||
app.use('/api/v1/users', usersRouter);
|
||||
// app.use('/api/v1/posts', usersRouter);
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
app.use(function(req, res, next) {
|
||||
|
||||
Reference in New Issue
Block a user