(extraEnv)
| 74 | // todo rewrite companion to not use global state |
| 75 | // https://github.com/transloadit/uppy/issues/3284 |
| 76 | export const getServer = async (extraEnv) => { |
| 77 | const { default: standalone } = await import('../src/standalone/index.js') |
| 78 | |
| 79 | const env = { |
| 80 | ...defaultEnv, |
| 81 | ...extraEnv, |
| 82 | } |
| 83 | |
| 84 | updateEnv(env) |
| 85 | |
| 86 | const authServer = express() |
| 87 | |
| 88 | authServer.use( |
| 89 | session({ secret: 'grant', resave: true, saveUninitialized: true }), |
| 90 | ) |
| 91 | authServer.all('*/callback', (req, res, next) => { |
| 92 | // @ts-ignore |
| 93 | req.session.grant = { |
| 94 | response: { access_token: grantToken }, |
| 95 | } |
| 96 | next() |
| 97 | }) |
| 98 | authServer.all(['*/send-token', '*/redirect'], (req, res, next) => { |
| 99 | // @ts-ignore |
| 100 | req.session.grant = { |
| 101 | dynamic: { state: req.query.state || 'non-empty-value' }, |
| 102 | } |
| 103 | next() |
| 104 | }) |
| 105 | |
| 106 | const { app } = standalone() |
| 107 | authServer.use(app) |
| 108 | return authServer |
| 109 | } |
searching dependent graphs…