replaced backend with vite
This commit is contained in:
@@ -51,6 +51,8 @@
|
||||
"rimraf": "^5.0.5",
|
||||
"rollup": "^4.9.6",
|
||||
"ts-node-dev": "^2.0.0",
|
||||
"typescript": "^5.2.2"
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.2.11",
|
||||
"vite-plugin-node": "^3.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import run from "@rollup/plugin-run";
|
||||
import typescript from '@rollup/plugin-typescript';
|
||||
import json from '@rollup/plugin-json';
|
||||
import copy from 'rollup-plugin-copy';
|
||||
import compileTime from "vite-plugin-compile-time";
|
||||
import dynamicImportVars from '@rollup/plugin-dynamic-import-vars';
|
||||
|
||||
const isDev = process.env.NODE_ENV !== "production";
|
||||
|
||||
export default {
|
||||
input: "src/index.ts",
|
||||
output: {
|
||||
dir: "dist/",
|
||||
format: "es",
|
||||
strict: false,
|
||||
},
|
||||
watch: {
|
||||
include: [ './src/**', '../shared-operations/src/**' ]
|
||||
},
|
||||
plugins: [
|
||||
compileTime(),
|
||||
json(),
|
||||
typescript(),
|
||||
dynamicImportVars({errorWhenNoFilesFound: true, warnOnError: true}),
|
||||
copy({
|
||||
targets: [
|
||||
{ src: '../shared-operations/public', dest: 'dist' },
|
||||
]
|
||||
}),
|
||||
isDev && run()
|
||||
],
|
||||
};
|
||||
@@ -1,4 +1,17 @@
|
||||
import "@stirling-pdf/shared-operations/src/i18next.config";
|
||||
import i18next from "i18next";
|
||||
import resourcesToBackend from "i18next-resources-to-backend";
|
||||
|
||||
i18next.use(resourcesToBackend((language: string, namespace: string) => import(`../../shared-operations/public/locales/${namespace}/${language}.json`)))
|
||||
.init({
|
||||
debug: true,
|
||||
ns: ["common"], // Preload this namespace, no need to add the others, they will load once their module is loaded
|
||||
defaultNS: "common",
|
||||
fallbackLng: "en",
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
initImmediate: false // Makes loading blocking but sync
|
||||
});
|
||||
|
||||
import express from "express";
|
||||
const app = express();
|
||||
@@ -13,10 +26,14 @@ import api from "./routes/api/api-controller";
|
||||
app.use("/api", api);
|
||||
|
||||
// serve
|
||||
app.listen(PORT, () => {
|
||||
console.log(`http://localhost:${PORT}`);
|
||||
});
|
||||
if (import.meta.env.PROD) {
|
||||
app.listen(PORT, () => {
|
||||
console.log(`http://localhost:${PORT}`);
|
||||
});
|
||||
}
|
||||
|
||||
process.on('unhandledRejection', (reason, promise) => {
|
||||
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
|
||||
});
|
||||
|
||||
export const viteNodeApp = app;
|
||||
@@ -43,6 +43,11 @@ router.post("/:workflowUuid?", [
|
||||
}
|
||||
}
|
||||
|
||||
if(!workflow.actions) {
|
||||
res.status(400).json({error: "The provided workflow does not contain any actions."});
|
||||
return
|
||||
}
|
||||
|
||||
const validationResults = await JoiPDFFileSchema.validateAsync(req.files);
|
||||
if(validationResults.error) {
|
||||
res.status(400).json({error: "PDF validation failed", details: validationResults.error.message});
|
||||
|
||||
32
server-node/vite.config.ts
Normal file
32
server-node/vite.config.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import topLevelAwait from "vite-plugin-top-level-await";
|
||||
import dynamicImport from 'vite-plugin-dynamic-import'
|
||||
import compileTime from "vite-plugin-compile-time"
|
||||
import { VitePluginNode } from 'vite-plugin-node';
|
||||
|
||||
export default defineConfig({
|
||||
// ...vite configures
|
||||
server: {
|
||||
// vite server configs, for details see [vite doc](https://vitejs.dev/config/#server-host)
|
||||
port: 8000
|
||||
},
|
||||
plugins: [
|
||||
...VitePluginNode({
|
||||
// Nodejs native Request adapter
|
||||
// currently this plugin support 'express', 'nest', 'koa' and 'fastify' out of box,
|
||||
// you can also pass a function if you are using other frameworks, see Custom Adapter section
|
||||
adapter: 'express',
|
||||
|
||||
// tell the plugin where is your project entry
|
||||
appPath: './src/index.ts',
|
||||
}),
|
||||
topLevelAwait({
|
||||
// The export name of top-level await promise for each chunk module
|
||||
promiseExportName: "__tla",
|
||||
// The function to generate import names of top-level await promise in each chunk module
|
||||
promiseImportName: i => `__tla_${i}`
|
||||
}),
|
||||
compileTime(),
|
||||
dynamicImport(),
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user