map routers gemaakt met router files in, backend/src/app.ts bevat verwijzingen naar deze files met app.use
This commit is contained in:
parent
c07bb959cf
commit
f45a9aa5a5
9 changed files with 112 additions and 0 deletions
|
@ -1,9 +1,18 @@
|
||||||
import express, { Express, Response } from 'express';
|
import express, { Express, Response } from 'express';
|
||||||
import initORM from './orm.js';
|
import initORM from './orm.js';
|
||||||
|
|
||||||
|
import studentRouter from './routes/student';
|
||||||
|
import groupRouter from './routes/group';
|
||||||
|
import assignmentRouter from './routes/assignment';
|
||||||
|
import submissionRouter from './routes/submission';
|
||||||
|
import classRouter from './routes/class';
|
||||||
|
import questionRouter from './routes/question';
|
||||||
|
import loginRouter from './routes/login';
|
||||||
|
|
||||||
const app: Express = express();
|
const app: Express = express();
|
||||||
const port: string | number = process.env.PORT || 3000;
|
const port: string | number = process.env.PORT || 3000;
|
||||||
|
|
||||||
|
|
||||||
// TODO Replace with Express routes
|
// TODO Replace with Express routes
|
||||||
app.get('/', (_, res: Response) => {
|
app.get('/', (_, res: Response) => {
|
||||||
res.json({
|
res.json({
|
||||||
|
@ -11,6 +20,15 @@ app.get('/', (_, res: Response) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.use('/student', studentRouter);
|
||||||
|
app.use('/group', groupRouter);
|
||||||
|
app.use('/assignment', assignmentRouter);
|
||||||
|
app.use('/submission', submissionRouter);
|
||||||
|
app.use('/class', classRouter);
|
||||||
|
app.use('/question', questionRouter);
|
||||||
|
app.use('/login', loginRouter);
|
||||||
|
|
||||||
|
|
||||||
async function startServer() {
|
async function startServer() {
|
||||||
await initORM();
|
await initORM();
|
||||||
|
|
||||||
|
|
9
backend/src/routes/assignment.ts
Normal file
9
backend/src/routes/assignment.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import express from 'express'
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
// information about an assignment with id 'id'
|
||||||
|
router.get('/:id', (req, res) => {
|
||||||
|
res.send('assignment');
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router
|
9
backend/src/routes/class.ts
Normal file
9
backend/src/routes/class.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import express from 'express'
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
// information about an class with id 'id'
|
||||||
|
router.get('/:id', (req, res) => {
|
||||||
|
res.send('class');
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router
|
14
backend/src/routes/group.ts
Normal file
14
backend/src/routes/group.ts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import express from 'express'
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
// information about a group (members, ... [TODO DOC])
|
||||||
|
router.get('/:id', (req, res) => {
|
||||||
|
res.send('group');
|
||||||
|
})
|
||||||
|
|
||||||
|
// the list of questions a group has made
|
||||||
|
router.get('/:id/questions', (req, res) => {
|
||||||
|
res.send('questions');
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router
|
9
backend/src/routes/login.ts
Normal file
9
backend/src/routes/login.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import express from 'express'
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
// returns login paths for IDP
|
||||||
|
router.get('/', (req, res) => {
|
||||||
|
res.send('login route');
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router
|
9
backend/src/routes/question.ts
Normal file
9
backend/src/routes/question.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import express from 'express'
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
// information about an question with id 'id'
|
||||||
|
router.get('/:id', (req, res) => {
|
||||||
|
res.send('question');
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router
|
25
backend/src/routes/student.ts
Normal file
25
backend/src/routes/student.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import express from 'express'
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
// the list of classes a student is in
|
||||||
|
router.get('/:id/classes', (req, res) => {
|
||||||
|
res.send('classes');
|
||||||
|
})
|
||||||
|
|
||||||
|
// the list of submissions a student has made
|
||||||
|
router.get('/:id/submissions', (req, res) => {
|
||||||
|
res.send('submissions');
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// the list of assignments a student has
|
||||||
|
router.get('/:id/assignments', (req, res) => {
|
||||||
|
res.send('assignments');
|
||||||
|
})
|
||||||
|
|
||||||
|
// the list of groups a student is in
|
||||||
|
router.get('/:id/group', (req, res) => {
|
||||||
|
res.send('groups');
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router
|
9
backend/src/routes/submission.ts
Normal file
9
backend/src/routes/submission.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import express from 'express'
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
// information about an submission with id 'id'
|
||||||
|
router.get('/:id', (req, res) => {
|
||||||
|
res.send('submission');
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router
|
10
backend/src/routes/themes.ts
Normal file
10
backend/src/routes/themes.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import express from 'express'
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
// I'm not sure what's supposed to be here
|
||||||
|
// https://github.com/SELab-2/Dwengo-1/issues/24
|
||||||
|
router.get('/', (req, res) => {
|
||||||
|
res.send('themes route');
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router
|
Loading…
Add table
Add a link
Reference in a new issue