ssnxd
02/22/2022, 9:45 AMssnxd
02/22/2022, 9:45 AMssnxd
02/22/2022, 9:47 AMdocker
version: '3.8'
services:
auth:
container_name: xxx-auth
image: supertokens/supertokens-postgresql
restart: always
environment:
POSTGRESQL_CONNECTION_URI: postgresql://xxx:helloworld@localhost:5432/xxx
ports:
- "3567:3567"
depends_on:
- "db"
db:
container_name: xxx-db
image: postgres
restart: always
environment:
POSTGRES_USER: xxx
POSTGRES_PASSWORD: helloworld
POSTGRES_DB: xxx
ports:
- "5432:5432"
volumes:
- $HOME/Desktop/PostgreSql-Snippets/infile:/infile
- pg_data:/var/lib/postgresql/data/
volumes:
pg_data:
ssnxd
02/22/2022, 9:48 AMssnxd
02/22/2022, 9:57 AMrp
02/22/2022, 10:00 AMpostgresql://xxx:helloworld@xxx-db:5432/xxx
rp
02/22/2022, 10:01 AMssnxd
02/22/2022, 10:03 AMrajivharlalka
02/24/2022, 7:53 PMrp
02/24/2022, 9:14 PMrajivharlalka
02/25/2022, 4:52 AMrp
02/25/2022, 4:57 AMbill92
02/25/2022, 4:59 AMrp
02/25/2022, 4:59 AMbill92
02/25/2022, 4:59 AMrajivharlalka
02/25/2022, 5:01 AMrajivharlalka
02/25/2022, 5:01 AMrp
02/25/2022, 5:18 AMbill92
02/25/2022, 5:20 AMbill92
02/25/2022, 5:20 AMrp
02/25/2022, 5:20 AMrajivharlalka
02/25/2022, 5:21 AMrp
02/25/2022, 5:21 AMbill92
02/25/2022, 5:21 AMrajivharlalka
02/25/2022, 5:22 AMconst initialize = async app => {
server = http.createServer(app);
app.use(bodyParser.urlencoded({extended: true}));
app.use(helmet());
initSupertokens();
app.use(
cors({
origin: function (origin, callback) {
if (config.get("cors.whitelist").indexOf(origin) !== -1 || config.get("cors.allowLocal")) {
// error - null, allowOrigin - true
callback(null, true);
} else {
app.use(function (err, req, res) {
res.status(403).json({
success: false,
statusCode: "NOT_ALLOWED_BY_CORS",
message: "You are not allowed to access this resource",
data: {},
});
});
// error - true, allowOrigin - false
callback(true, false);
}
},
allowedHeaders: ["content-type", ...supertokens.getAllCORSHeaders()],
credentials: true,
})
);
app.use(middleware());
app.get("/health", (req, res) => {
res.status(200).send({PBL: "Up and Running"});
});
app.use(errorHandler());
app.enable("trust proxy");
server.listen(config.api.port);
server.timeout = config.get("server.timeout");
logger.info(`Server started at port ${config.api.port}`);
};
And this init function is called at the start of the Apprp
02/25/2022, 5:22 AMrp
02/25/2022, 5:23 AMrajivharlalka
02/25/2022, 5:23 AMconst initSupertokens = () => {
supertokens.init({
framework: "express",
supertokens: {
// These are the connection details of the app you created on supertokens.io
connectionURI: config.supertokens.url,
apiKey: config.supertokens.api_key,
},
appInfo: {
// learn more about this on https://supertokens.io/docs/session/appinfo
appName: "griffin",
apiDomain: config.urls.backend,
websiteDomain: config.urls.frontend,
apiBasePath: "/api",
websiteBasePath: "/auth",
},
recipeList: [
Passwordless.init({
flowType: "USER_INPUT_CODE",
contactMethod: "EMAIL_OR_PHONE",
createAndSendCustomEmail: async function (input) {
sendEmailOtp(input.email, input.userInputCode);
},
createAndSendCustomTextMessage: async (input, context) => {
/* See next step */
},
}),
,
Session.init(),
],
});
Logger.info("Supertokens connected.");
};
And this is the SuperTokens Init functionrajivharlalka
02/25/2022, 5:24 AMrp
02/25/2022, 5:24 AM