-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
26 lines (19 loc) · 810 Bytes
/
index.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
import express, { NextFunction, Request, Response } from 'express';
import morgan from 'morgan'
import actions from './actions';
const app = express();
app.use(morgan('combined'));
app.use(express.json());
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', 'https://chat.openai.com');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', '*');
if (req.method === "OPTIONS") return res.status(200).end();
next();
});
actions.get.forEach((action) => app.get(action.path, action.controller))
actions.post.forEach((action) => app.post(action.path, action.controller))
app.use(express.static('static'));
app.listen(8008, () => {
console.log('gpteer listening on port 8008');
});