mirror of
https://github.com/myfatemi04/wheelshare-old-backend.git
synced 2025-05-03 17:29:50 -04:00
Add create_session method
This commit is contained in:
parent
530a3f54d2
commit
a3afcee979
17
src/api.ts
17
src/api.ts
|
@ -1,4 +1,5 @@
|
||||||
import { Router } from 'express';
|
import { Router } from 'express';
|
||||||
|
import { createSessionFromCodeAndProvider } from './auth';
|
||||||
import {
|
import {
|
||||||
getGroupByID,
|
getGroupByID,
|
||||||
getPoolByID,
|
getPoolByID,
|
||||||
|
@ -147,3 +148,19 @@ router.post('/my_pools', (req, res) => {
|
||||||
res.json({ status: 'success' });
|
res.json({ status: 'success' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.get('/create_session', (req, res) => {
|
||||||
|
res.send('hello');
|
||||||
|
});
|
||||||
|
|
||||||
|
router.post('/create_session', (req, res) => {
|
||||||
|
const { code, provider } = req.body;
|
||||||
|
console.log('Creating session: code =', code, 'provider =', provider);
|
||||||
|
createSessionFromCodeAndProvider(code, provider)
|
||||||
|
.then((token) => {
|
||||||
|
res.json({ status: 'success', session_token: token });
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
res.json({ status: 'error' });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
12
src/index.ts
12
src/index.ts
|
@ -1,7 +1,8 @@
|
||||||
import express from 'express';
|
import * as bodyParser from 'body-parser';
|
||||||
import dotenv from 'dotenv';
|
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import { users, groups } from './data';
|
import dotenv from 'dotenv';
|
||||||
|
import express from 'express';
|
||||||
|
import * as api from './api';
|
||||||
|
|
||||||
dotenv.config({
|
dotenv.config({
|
||||||
path: '.env',
|
path: '.env',
|
||||||
|
@ -9,7 +10,10 @@ dotenv.config({
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
app.use(cors);
|
app.use(cors());
|
||||||
|
app.use(bodyParser.json());
|
||||||
|
|
||||||
|
app.use('/api', api.router);
|
||||||
|
|
||||||
((port = process.env.APP_PORT || 5000) => {
|
((port = process.env.APP_PORT || 5000) => {
|
||||||
app.listen(port, () => void console.log(`Listening on port ${port}`));
|
app.listen(port, () => void console.log(`Listening on port ${port}`));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user