Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created July 14, 2020 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/70145d85814521f2343af6b59db45634 to your computer and use it in GitHub Desktop.
Save velotiotech/70145d85814521f2343af6b59db45634 to your computer and use it in GitHub Desktop.
import { Request, Response, Router } from 'express';
import { BAD_REQUEST, CREATED, OK } from 'http-status-codes';
import { ParamsDictionary } from 'express-serve-static-core';
import { getConnection } from "typeorm";
import { User } from "../entities/User";
import { paramMissingError } from '../shared/constants';
const router = Router();
router.get('/all', async (req: Request, res: Response) => {
const users = await getConnection()
.getRepository(User)
.createQueryBuilder("user")
.getMany();
return res.status(OK).json({users});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment