-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi.ts
35 lines (27 loc) · 1.01 KB
/
api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import express, { Request, Response } from 'express';
import { join } from 'path';
import * as fs from 'fs';
const { version } = require('./data/json/api.json');
const app = express();
const PORT = 3000;
function responseFile(path: string){
return JSON.parse(fs.readFileSync(path, "utf8"));
}
app.get('/', (req: Request, res: Response) => {
res.json(responseFile("data/json/api.json"));
});
app.get('/team', (req: Request, res: Response) => {
res.json(responseFile("data/json/team.json"));
});
app.get('/messages', (req: Request, res: Response) => {
res.json(responseFile("data/json/messages.json"));
});
app.get('/latestVersion/:platform', (req: Request, res: Response) => {
res.json(responseFile(`data/json/latestVersion${req.params.platform}.json`));
});
app.get('/staff/:name/photo', (req: Request, res: Response) => {
res.json(responseFile(`data/img/staff_${req.params.name}.json`));
});
app.listen(PORT, () => {
console.log(`PapiAPI est joignable via le port ${PORT} en version ${version} !`);
});