lots of layout; server not really running yet
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { Express } from "express"
|
||||
import { userRoute } from "./users";
|
||||
|
||||
export const routes = (app: Express, passport?: any) => {
|
||||
console.log('routes called');
|
||||
|
||||
userRoute(app);
|
||||
|
||||
app.get('/hello', (req, res) => {
|
||||
res.send({ message: "hello from the server!!" });
|
||||
})
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import db, { sql } from '../db';
|
||||
import { Express, Router } from 'express';
|
||||
import UserCtl from '../controllers/UserCtl';
|
||||
const router = Router();
|
||||
const userCtl = new UserCtl();
|
||||
|
||||
export const userRoute = (app: Express) => {
|
||||
app.use('/users', router);
|
||||
|
||||
// get all users
|
||||
router.get('/', async (req, res, next) => {
|
||||
await db.query(sql`SELECT * FROM users`).then(response => console.log(response));
|
||||
// const data = userCtl.getAll();
|
||||
// res.status(200).send(data);
|
||||
})
|
||||
|
||||
router.get('/hidden-thing', (req, res) => {
|
||||
res.send('does this route actually work?');
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user