chore: Use ES modules for backend app
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import express from 'express';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const appAssetsHandler = async (app) => {
|
||||
app.use('/apps/:appKey/assets/favicon.svg', (req, res, next) => {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { allow, rule, shield } from 'graphql-shield';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import appConfig from '../config/app';
|
||||
import User from '../models/user';
|
||||
import appConfig from '../config/app.js';
|
||||
import User from '../models/user.js';
|
||||
|
||||
const isAuthenticated = rule()(async (_parent, _args, req) => {
|
||||
const token = req.headers['authorization'];
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import appConfig from '../../config/app';
|
||||
import paddleClient from './paddle.ee';
|
||||
import paddlePlans from './plans.ee';
|
||||
import webhooks from './webhooks.ee';
|
||||
import appConfig from '../../config/app.js';
|
||||
import paddleClient from './paddle.ee.js';
|
||||
import paddlePlans from './plans.ee.js';
|
||||
import webhooks from './webhooks.ee.js';
|
||||
|
||||
const paddleInfo = {
|
||||
sandbox: appConfig.isProd ? false : true,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// TODO: replace with axios-with-proxy when needed
|
||||
import axios from 'axios';
|
||||
import appConfig from '../../config/app';
|
||||
import appConfig from '../../config/app.js';
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
const PADDLE_VENDOR_URL = appConfig.isDev
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import Subscription from '../../models/subscription.ee';
|
||||
import Billing from './index.ee';
|
||||
import Subscription from '../../models/subscription.ee.js';
|
||||
import Billing from './index.ee.js';
|
||||
|
||||
const handleSubscriptionCreated = async (request) => {
|
||||
const subscription = await Subscription.query().insertAndFetch(
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import jwt from 'jsonwebtoken';
|
||||
import appConfig from '../config/app';
|
||||
import appConfig from '../config/app.js';
|
||||
|
||||
const TOKEN_EXPIRES_IN = '14d';
|
||||
|
||||
|
@@ -1,13 +1,13 @@
|
||||
import { ExpressAdapter } from '@bull-board/express';
|
||||
import { createBullBoard } from '@bull-board/api';
|
||||
import { BullMQAdapter } from '@bull-board/api/bullMQAdapter';
|
||||
import flowQueue from '../queues/flow';
|
||||
import triggerQueue from '../queues/trigger';
|
||||
import actionQueue from '../queues/action';
|
||||
import emailQueue from '../queues/email';
|
||||
import deleteUserQueue from '../queues/delete-user.ee';
|
||||
import removeCancelledSubscriptionsQueue from '../queues/remove-cancelled-subscriptions.ee';
|
||||
import appConfig from '../config/app';
|
||||
import { BullMQAdapter } from '@bull-board/api/bullMQAdapter.js';
|
||||
import flowQueue from '../queues/flow.js';
|
||||
import triggerQueue from '../queues/trigger.js';
|
||||
import actionQueue from '../queues/action.js';
|
||||
import emailQueue from '../queues/email.js';
|
||||
import deleteUserQueue from '../queues/delete-user.ee.js';
|
||||
import removeCancelledSubscriptionsQueue from '../queues/remove-cancelled-subscriptions.ee.js';
|
||||
import appConfig from '../config/app.js';
|
||||
|
||||
const serverAdapter = new ExpressAdapter();
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import logger from './logger';
|
||||
import logger from './logger.js';
|
||||
|
||||
// Do not remove `next` argument as the function signature will not fit for an error handler middleware
|
||||
const errorHandler = (err, req, res, next) => {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import User from '../models/user';
|
||||
import Identity from '../models/identity.ee';
|
||||
import User from '../models/user.js';
|
||||
import Identity from '../models/identity.ee.js';
|
||||
|
||||
const getUser = (user, providerConfig) => ({
|
||||
name: user[providerConfig.firstnameAttributeName],
|
||||
|
@@ -1,16 +1,19 @@
|
||||
import { join } from 'node:path';
|
||||
import path, { join } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { graphqlHTTP } from 'express-graphql';
|
||||
import { loadSchemaSync } from '@graphql-tools/load';
|
||||
import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader';
|
||||
import { addResolversToSchema } from '@graphql-tools/schema';
|
||||
import { applyMiddleware } from 'graphql-middleware';
|
||||
|
||||
import appConfig from '../config/app';
|
||||
import logger from './logger';
|
||||
import authentication from './authentication';
|
||||
import * as Sentry from './sentry.ee';
|
||||
import resolvers from '../graphql/resolvers';
|
||||
import HttpError from '../errors/http';
|
||||
import appConfig from '../config/app.js';
|
||||
import logger from './logger.js';
|
||||
import authentication from './authentication.js';
|
||||
import * as Sentry from './sentry.ee.js';
|
||||
import resolvers from '../graphql/resolvers.js';
|
||||
import HttpError from '../errors/http.js';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const schema = loadSchemaSync(join(__dirname, '../graphql/schema.graphql'), {
|
||||
loaders: [new GraphQLFileLoader()],
|
||||
@@ -22,7 +25,10 @@ const schemaWithResolvers = addResolversToSchema({
|
||||
});
|
||||
|
||||
const graphQLInstance = graphqlHTTP({
|
||||
schema: applyMiddleware(schemaWithResolvers, authentication),
|
||||
schema: applyMiddleware(
|
||||
schemaWithResolvers,
|
||||
authentication.generate(schemaWithResolvers)
|
||||
),
|
||||
graphiql: appConfig.isDev,
|
||||
customFormatErrorFn: (error) => {
|
||||
logger.error(error.path + ' : ' + error.message + '\n' + error.stack);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import basicAuth from 'express-basic-auth';
|
||||
import appConfig from '../config/app';
|
||||
import appConfig from '../config/app.js';
|
||||
|
||||
const injectBullBoardHandler = async (app, serverAdapter) => {
|
||||
if (
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import morgan from 'morgan';
|
||||
import logger from './logger';
|
||||
import logger from './logger.js';
|
||||
|
||||
const stream = {
|
||||
write: (message) =>
|
||||
|
@@ -2,10 +2,10 @@ import { URL } from 'node:url';
|
||||
import { MultiSamlStrategy } from '@node-saml/passport-saml';
|
||||
import passport from 'passport';
|
||||
|
||||
import appConfig from '../config/app';
|
||||
import createAuthTokenByUserId from './create-auth-token-by-user-id';
|
||||
import SamlAuthProvider from '../models/saml-auth-provider.ee';
|
||||
import findOrCreateUserBySamlIdentity from './find-or-create-user-by-saml-identity.ee';
|
||||
import appConfig from '../config/app.js';
|
||||
import createAuthTokenByUserId from './create-auth-token-by-user-id.js';
|
||||
import SamlAuthProvider from '../models/saml-auth-provider.ee.js';
|
||||
import findOrCreateUserBySamlIdentity from './find-or-create-user-by-saml-identity.ee.js';
|
||||
|
||||
export default function configurePassport(app) {
|
||||
app.use(
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { dirname, join } from 'path';
|
||||
import appConfig from '../config/app';
|
||||
import appConfig from '../config/app.js';
|
||||
|
||||
const webUIHandler = async (app) => {
|
||||
if (appConfig.serveWebAppSeparately) return;
|
||||
|
@@ -1,14 +1,14 @@
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import isEmpty from 'lodash/isEmpty.js';
|
||||
|
||||
import Flow from '../models/flow';
|
||||
import { processTrigger } from '../services/trigger';
|
||||
import triggerQueue from '../queues/trigger';
|
||||
import globalVariable from './global-variable';
|
||||
import QuotaExceededError from '../errors/quote-exceeded';
|
||||
import Flow from '../models/flow.js';
|
||||
import { processTrigger } from '../services/trigger.js';
|
||||
import triggerQueue from '../queues/trigger.js';
|
||||
import globalVariable from './global-variable.js';
|
||||
import QuotaExceededError from '../errors/quote-exceeded.js';
|
||||
import {
|
||||
REMOVE_AFTER_30_DAYS_OR_150_JOBS,
|
||||
REMOVE_AFTER_7_DAYS_OR_50_JOBS,
|
||||
} from './remove-job-configuration';
|
||||
} from './remove-job-configuration.js';
|
||||
|
||||
export default async (flowId, request, response) => {
|
||||
const flow = await Flow.query().findById(flowId).throwIfNotFound();
|
||||
|
Reference in New Issue
Block a user