mirror of
https://github.com/wassname/talk.git
synced 2026-07-12 19:30:13 +08:00
feat: production updates
This commit is contained in:
+1
-1
@@ -46,7 +46,7 @@ module.exports = {
|
||||
appPostCssConfig: resolveApp("config/postcss.config.js"),
|
||||
appJestConfig: resolveApp("config/jest.config.js"),
|
||||
appLoaders: resolveApp("loaders"),
|
||||
appDist: resolveApp("dist"),
|
||||
appDist: resolveApp("dist/static"),
|
||||
appPublic: resolveApp("public"),
|
||||
appPackageJson: resolveApp("package.json"),
|
||||
appSrc: resolveApp("src"),
|
||||
|
||||
@@ -39,7 +39,7 @@ if (env.stringified["process.env"].NODE_ENV !== '"production"') {
|
||||
// because of this bug https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/763.
|
||||
// TODO: Repalce with mini-css-extract-plugin once it supports HMR.
|
||||
// https://github.com/webpack-contrib/mini-css-extract-plugin
|
||||
const cssFilename = "static/css/[name].[md5:contenthash:hex:20].css";
|
||||
const cssFilename = "assets/css/[name].[md5:contenthash:hex:20].css";
|
||||
|
||||
// ExtractTextPlugin expects the build output to be flat.
|
||||
// (See https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/27)
|
||||
@@ -72,8 +72,8 @@ module.exports = {
|
||||
// Generated JS file names (with nested folders).
|
||||
// There will be one main bundle, and one file per asynchronous chunk.
|
||||
// We don't currently advertise code splitting but Webpack supports it.
|
||||
filename: "static/js/[name].[chunkhash:8].js",
|
||||
chunkFilename: "static/js/[name].[chunkhash:8].chunk.js",
|
||||
filename: "assets/js/[name].[chunkhash:8].js",
|
||||
chunkFilename: "assets/js/[name].[chunkhash:8].chunk.js",
|
||||
// We inferred the "public path" (such as / or /my-project) from homepage.
|
||||
publicPath: publicPath,
|
||||
// Point sourcemap entries to original disk location (format as URL on Windows)
|
||||
@@ -210,7 +210,7 @@ module.exports = {
|
||||
loader: require.resolve("url-loader"),
|
||||
options: {
|
||||
limit: 10000,
|
||||
name: "static/media/[name].[hash:8].[ext]",
|
||||
name: "assets/media/[name].[hash:8].[ext]",
|
||||
},
|
||||
},
|
||||
// Process JS with Babel.
|
||||
@@ -299,7 +299,7 @@ module.exports = {
|
||||
exclude: [/\.(js|jsx|mjs|ts|tsx)$/, /\.html$/, /\.json$/],
|
||||
loader: require.resolve("file-loader"),
|
||||
options: {
|
||||
name: "static/media/[name].[hash:8].[ext]",
|
||||
name: "assets/media/[name].[hash:8].[ext]",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -31,7 +31,7 @@ export interface SignupOptions {
|
||||
db: Db;
|
||||
}
|
||||
|
||||
export const signup = ({ db }: SignupOptions): RequestHandler => async (
|
||||
export const signupHandler = ({ db }: SignupOptions): RequestHandler => async (
|
||||
req: Request,
|
||||
res,
|
||||
next
|
||||
@@ -42,6 +42,7 @@ export const signup = ({ db }: SignupOptions): RequestHandler => async (
|
||||
// Tenant is guaranteed at this point.
|
||||
const tenant = req.tenant!;
|
||||
|
||||
// Check to ensure that the local integration has been enabled.
|
||||
if (!tenant.auth.integrations.local.enabled) {
|
||||
// TODO: replace with better error.
|
||||
return next(new Error("integration is disabled"));
|
||||
|
||||
@@ -3,6 +3,7 @@ import http from "http";
|
||||
import { Redis } from "ioredis";
|
||||
import { Db } from "mongodb";
|
||||
|
||||
import { notFoundMiddleware } from "talk-server/app/middleware/notFound";
|
||||
import { createPassport } from "talk-server/app/middleware/passport";
|
||||
import { Config } from "talk-server/config";
|
||||
import { handleSubscriptions } from "talk-server/graph/common/subscriptions/middleware";
|
||||
@@ -30,16 +31,17 @@ export async function createApp(options: AppOptions): Promise<Express> {
|
||||
// Logging
|
||||
parent.use(accessLogger);
|
||||
|
||||
// Static Files
|
||||
parent.use(serveStatic);
|
||||
|
||||
// Create some services for the router.
|
||||
const passport = createPassport({ db: options.mongo });
|
||||
|
||||
// Mount the router.
|
||||
parent.use(await createRouter(options, { passport }));
|
||||
|
||||
// Static Files
|
||||
parent.use(serveStatic);
|
||||
|
||||
// Error Handling
|
||||
parent.use(notFoundMiddleware);
|
||||
parent.use(errorLogger);
|
||||
|
||||
return parent;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { RequestHandler } from "express";
|
||||
|
||||
export const notFoundMiddleware: RequestHandler = (req, res, next) => {
|
||||
next(new Error("not found"));
|
||||
};
|
||||
@@ -1,14 +1,14 @@
|
||||
import express from "express";
|
||||
import passport from "passport";
|
||||
|
||||
import { signupHandler } from "talk-server/app/handlers/auth/local";
|
||||
import { apiErrorHandler } from "talk-server/app/middleware/error";
|
||||
import { errorLogger } from "talk-server/app/middleware/logging";
|
||||
import { authenticate } from "talk-server/app/middleware/passport";
|
||||
import tenantMiddleware from "talk-server/app/middleware/tenant";
|
||||
import managementGraphMiddleware from "talk-server/graph/management/middleware";
|
||||
import tenantGraphMiddleware from "talk-server/graph/tenant/middleware";
|
||||
|
||||
import { signup } from "talk-server/app/handlers/auth/local";
|
||||
import { apiErrorHandler } from "talk-server/app/middleware/error";
|
||||
import { errorLogger } from "talk-server/app/middleware/logging";
|
||||
import { authenticate } from "talk-server/app/middleware/passport";
|
||||
import { AppOptions } from "./index";
|
||||
import playground from "./middleware/playground";
|
||||
|
||||
@@ -59,7 +59,11 @@ function createNewAuthRouter(app: AppOptions, options: RouterOptions) {
|
||||
express.json(),
|
||||
authenticate(options.passport, "local")
|
||||
);
|
||||
router.post("/local/signup", express.json(), signup({ db: app.mongo }));
|
||||
router.post(
|
||||
"/local/signup",
|
||||
express.json(),
|
||||
signupHandler({ db: app.mongo })
|
||||
);
|
||||
router.get("/oidc", authenticate(options.passport, "oidc"));
|
||||
router.get("/oidc/callback", authenticate(options.passport, "oidc"));
|
||||
// router.get("/google", options.passport.authenticate("google"));
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import convict from "convict";
|
||||
import dotenv from "dotenv";
|
||||
import Joi from "joi";
|
||||
|
||||
// Apply all the configuration provided in the .env file if it isn't already in
|
||||
// the environment.
|
||||
dotenv.config();
|
||||
|
||||
// Add custom format for the mongo uri scheme.
|
||||
convict.addFormat({
|
||||
name: "mongo-uri",
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import dotenv from "dotenv";
|
||||
|
||||
// Apply all the configuration provided in the .env file if it isn't already in
|
||||
// the environment.
|
||||
dotenv.config();
|
||||
|
||||
import express from "express";
|
||||
|
||||
import logger from "talk-server/logger";
|
||||
|
||||
Reference in New Issue
Block a user