File tree Expand file tree Collapse file tree 3 files changed +1
-59
lines changed
examples_new/microservices/items/src Expand file tree Collapse file tree 3 files changed +1
-59
lines changed Original file line number Diff line number Diff line change 11import { Response } from 'express' ;
22import axios , { AxiosError } from 'axios' ;
3- import {
4- BadRequestError ,
5- CurrentUserRequest ,
6- EventTypes ,
7- NotAuthorizedError ,
8- } from '@chronosrx/common' ;
3+ import { BadRequestError , CurrentUserRequest , EventTypes } from '@chronosrx/common' ;
94import { Item } from '../models/items' ;
105
11- // current users can create items to sell
126export const createItem = async ( req : CurrentUserRequest , res : Response ) => {
13- // req.body consists of itemName and unitPrice
147 const { itemName } = req . body ;
158 if ( ! itemName ) {
169 throw new BadRequestError ( 'Invalid inputs' ) ;
1710 }
1811
19- // new item is created with the build method and then saved
2012 const newItem = Item . build ( {
2113 itemName,
2214 } ) ;
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import mongoose from 'mongoose';
33import { app } from './app' ;
44import { DbConnectionError } from '@chronosrx/common' ;
55import { Item } from './models/items' ;
6- import { User } from './models/users' ;
76import dotenv from 'dotenv' ;
87dotenv . config ( { path : path . resolve ( __dirname + '../../.env' ) } ) ;
98
@@ -19,7 +18,6 @@ const start = async () => {
1918 console . log ( '🍃 Connected to MongoDB' ) ;
2019
2120 // reset DB's
22- await User . deleteMany ( ) ;
2321 await Item . deleteMany ( ) ;
2422 } catch ( err ) {
2523 throw new DbConnectionError ( ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments