import { UserContext } from '@nx-mean-starter/backend/schemas' ; import { generateUsers } from '@nx-mean-starter/dev' ; import { User } from '@nx-mean-starter/models' ; import { queryToParams } from '@nx-mean-starter/shared' ; import { Request , Response , Router } from 'express' ; export const usersRouter = Router ( ) ; usersRouter . get ( '/' , async ( req , res ) => { const { filter , skip , limit , sort , projection } = queryToParams ( req . query ) ; const users = await UserContext . find ( filter ) . skip ( skip ) . limit ( limit ) . sort ( sort ) . select ( projection ) . lean ( ) ; res . send ( users ) ; } ) ; usersRouter . get ( '/:id' , async ( req , res ) => { const id = req . params . id ; const user = await UserContext . findById ( id ) . lean ( ) ; res . send ( user ) ; } ) ; usersRouter . get ( '/generate/:count' , async ( req , res ) => { const count = req . params . count ; const users = await UserContext . create ( generateUsers ( count ) ) ; res . send ( users ) ; } ) ;