Supbase login + waiting list page
This commit is contained in:
+29
-5
@@ -1,18 +1,42 @@
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
import { json } from 'body-parser';
|
||||
import sirv from 'sirv';
|
||||
import polka from 'polka';
|
||||
import express from 'express';
|
||||
import compression from 'compression';
|
||||
import * as sapper from '@sapper/server';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import { getSupabase } from './utils/functions/supabase';
|
||||
|
||||
import config from './config';
|
||||
dotenv.config();
|
||||
|
||||
polka() // You can also use Express
|
||||
const config = {
|
||||
telegramToken: process.env.SVELTE_APP_TELEGRAM_API_TOKEN,
|
||||
supabaseConfig: {
|
||||
url: process.env.SVELTE_APP_SUPABASE_URL,
|
||||
anonKey: process.env.SVELTE_APP_SUPABASE_ANON_KEY,
|
||||
},
|
||||
};
|
||||
|
||||
const supabase = getSupabase(config);
|
||||
|
||||
express() // You can also use Express
|
||||
.use(cookieParser())
|
||||
.use(json())
|
||||
.use(
|
||||
compression({ threshold: 0 }),
|
||||
sirv('static', { dev: true }),
|
||||
sapper.middleware()
|
||||
sapper.middleware({
|
||||
session: async (req) => {
|
||||
const { user } = await supabase.auth.api.getUserByCookie(req);
|
||||
|
||||
return {
|
||||
user: JSON.stringify(user),
|
||||
config,
|
||||
};
|
||||
},
|
||||
})
|
||||
)
|
||||
.listen(config.port, (err) => {
|
||||
.listen(process.env.PORT, (err) => {
|
||||
if (err) console.log('error', err);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user