Skip to content
This repository was archived by the owner on Mar 15, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const app = express();
const port = process.env.PORT || 5000;

// config

// express.json middleware allows handling request JSON payloads
app.use(express.json() as any);

// routes
Expand All @@ -24,10 +26,11 @@ app.get('/hello', (_req, res) => {

app.options('/auth', async (_req, res) => {
res
.header('Access-Control-Allow-Headers', 'content-type')
.header('Access-Control-Allow-Methods', 'GET,HEAD,PUT,PATCH,POST,DELETE')
.header('Access-Control-Allow-Origin', '*')
.header('Content-Length', '0')
.set({
'Access-Control-Allow-Headers': 'content-type',
'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE',
'Access-Control-Allow-Origin': '*',
})
.status(204);
});

Expand All @@ -48,16 +51,17 @@ app.post('/auth', async (req, res) => {

res
.contentType('application/json')
.header('Access-Control-Allow-Origin', '*')
.set({ 'Access-Control-Allow-Origin': '*' })
.status(200)
.send(responsePayload);
});

app.listen(port, () => console.log(`Listening on port ${port}`));

app.get('/test', (_req, res) => {
res
.contentType('text/plain')
.header({ 'Access-Control-Allow-Origin': '*' })
.status(200)
.send('test response 1');
});

app.listen(port, () => console.log(`Listening on port ${port}`));