File tree Expand file tree Collapse file tree
examples_new/microservices/inventory Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020 "dependencies" : {
2121 "@chronosrx/common" : " ^1.0.4" ,
2222 "cookie-parser" : " ^1.4.6" ,
23+ "cors" : " ^2.8.5" ,
2324 "dotenv" : " ^16.3.1" ,
2425 "express" : " ^4.18.2" ,
2526 "express-async-errors" : " ^3.1.1" ,
2829 },
2930 "devDependencies" : {
3031 "@types/cookie-parser" : " ^1.4.6" ,
32+ "@types/cors" : " ^2.8.17" ,
3133 "@types/express" : " ^4.17.21" ,
3234 "@types/jest" : " ^29.5.11" ,
3335 "@types/supertest" : " ^2.0.16" ,
Original file line number Diff line number Diff line change @@ -2,12 +2,19 @@ import express from 'express';
22import 'express-async-errors' ;
33import dotenv from 'dotenv' ;
44dotenv . config ( ) ;
5+ import cors from 'cors' ;
56import { NotFoundError , errorHandler } from '@chronosrx/common' ;
67import inventoryRouter from './routes/inventory-router' ;
78import cookieParser from 'cookie-parser' ;
89import eventRouter from './routes/event-router' ;
910
1011const app = express ( ) ;
12+ app . use (
13+ cors ( {
14+ credentials : true ,
15+ origin : 'http://localhost:8080' ,
16+ } )
17+ ) ;
1118app . use ( express . json ( ) ) ;
1219app . use ( cookieParser ( ) ) ;
1320
Original file line number Diff line number Diff line change 11import { DbConnectionError } from '@chronosrx/common' ;
22import { app } from './app' ;
33import mongoose from 'mongoose' ;
4+ import { Inventory } from './models/Inventory' ;
5+ import { User } from './models/user' ;
46
57const PORT = process . env . PORT || 3000 ;
68
@@ -12,6 +14,10 @@ const start = async () => {
1214 try {
1315 await mongoose . connect ( process . env . MONGO_URI , { } ) ;
1416 console . log ( '🍃 Connected to MongoDB' ) ;
17+
18+ // reset DB's
19+ await Inventory . deleteMany ( ) ;
20+ await User . deleteMany ( ) ;
1521 } catch ( err ) {
1622 throw new DbConnectionError ( ) ;
1723 }
You can’t perform that action at this time.
0 commit comments