[Server] ✌️
This commit is contained in:
parent
5bdb407979
commit
f30262530d
|
@ -53,4 +53,11 @@ endpoints.forEach(endpoint =>
|
||||||
app.post('/signup', require('./private/signup').default);
|
app.post('/signup', require('./private/signup').default);
|
||||||
app.post('/signin', require('./private/signin').default);
|
app.post('/signin', require('./private/signin').default);
|
||||||
|
|
||||||
|
app.use((req, res, next) => {
|
||||||
|
res.locals.user = ((req.headers['cookie'] || '').match(/i=(!\w+)/) || [null, null])[1];
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
|
require('./service/twitter')(app);
|
||||||
|
|
||||||
module.exports = app;
|
module.exports = app;
|
||||||
|
|
|
@ -14,7 +14,7 @@ module.exports = (app: express.Application) => {
|
||||||
callbackUrl: config.url + '/tw/cb'
|
callbackUrl: config.url + '/tw/cb'
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get(/\/connect:twitter/, async (req, res): Promise<any> => {
|
app.get('connect/twitter', async (req, res): Promise<any> => {
|
||||||
if (res.locals.user == null) return res.send('plz signin');
|
if (res.locals.user == null) return res.send('plz signin');
|
||||||
const ctx = await twAuth.begin();
|
const ctx = await twAuth.begin();
|
||||||
redis.set(res.locals.user, JSON.stringify(ctx));
|
redis.set(res.locals.user, JSON.stringify(ctx));
|
|
@ -28,9 +28,6 @@ app.use(compression());
|
||||||
*/
|
*/
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
res.header('X-Frame-Options', 'DENY');
|
res.header('X-Frame-Options', 'DENY');
|
||||||
|
|
||||||
res.locals.user = ((req.headers['cookie'] || '').match(/i=(!\w+)/) || [null, null])[1];
|
|
||||||
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -51,8 +48,6 @@ app.get(/\/api:meta/, require('./meta'));
|
||||||
app.get(/\/api:url/, require('./service/url-preview'));
|
app.get(/\/api:url/, require('./service/url-preview'));
|
||||||
app.post(/\/api:rss/, require('./service/rss-proxy'));
|
app.post(/\/api:rss/, require('./service/rss-proxy'));
|
||||||
|
|
||||||
require('./service/twitter')(app);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subdomain
|
* Subdomain
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue