fixed 'added 'refreshToken', converted to 'httpOnly', added SSL
fixed 'gql-types' generator
This commit is contained in:
parent
d179b8c7c8
commit
c190d368de
20 changed files with 314 additions and 179 deletions
|
|
@ -5,20 +5,25 @@ import cors from 'cors';
|
|||
import 'dotenv/config';
|
||||
import express from 'express';
|
||||
import fs from 'fs';
|
||||
import http from 'http';
|
||||
import https from 'https';
|
||||
import path from 'path';
|
||||
import ViteExpress from 'vite-express';
|
||||
import { Mutation, Query } from './graphql/graphql';
|
||||
import { getIdentityContext, IdentityContext } from './identity';
|
||||
|
||||
import { Mutation, Query } from './graphql/graphql';
|
||||
const MODE = process.env.VITE_MODE || 'prod';
|
||||
const isProd = MODE === 'prod';
|
||||
|
||||
const __dirname = import.meta.dirname;
|
||||
const HOST = process.env.VITE_HOST || 'localhost';
|
||||
const PORT = parseInt(process.env.VITE_PORT || '3000');
|
||||
const MOTD = `\n\n\n\x1b[35m-server is listening at...-\x1b[0m\n\nhttp://${HOST}:${PORT}\nhttp://localhost:${PORT}\n\n\n`;
|
||||
|
||||
const key = fs.readFileSync(path.join(__dirname + '../../../certs/selfsigned.key'));
|
||||
const cert = fs.readFileSync(path.join(__dirname + '../../../certs/selfsigned.crt'));
|
||||
|
||||
const app = express();
|
||||
const server = http.createServer(app);
|
||||
const server = https.createServer({ key, cert }, app);
|
||||
|
||||
const typeDefs = fs.readFileSync(path.join(__dirname, 'graphql', 'schema.graphql'), 'utf8');
|
||||
|
||||
|
|
@ -31,12 +36,12 @@ const resolvers = {
|
|||
const apollo = new ApolloServer<IdentityContext>({
|
||||
typeDefs,
|
||||
resolvers,
|
||||
introspection: !isProd,
|
||||
plugins: [ApolloServerPluginDrainHttpServer({ httpServer: server })],
|
||||
formatError: (formattedError, error) => {
|
||||
formatError: formattedError => {
|
||||
process.stdout.write('\n```\n');
|
||||
console.error(`${error}`);
|
||||
console.error(formattedError);
|
||||
process.stdout.write('\n```\n');
|
||||
|
||||
return formattedError;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue