diff --git a/packages/accounts/package.json b/packages/accounts/package.json index f1e77a7065..0967e7f576 100644 --- a/packages/accounts/package.json +++ b/packages/accounts/package.json @@ -13,7 +13,8 @@ ], "license": "MIT", "scripts": { - "start": "cross-env NODE_ENV=development nodemon -w src -x ts-node server.ts", + "start": "cross-env NODE_ENV=development nodemon -w src -x ts-node steedos-server.ts", + "server": "cross-env NODE_ENV=development nodemon -w src -x ts-node server.ts", "build": "tsc && yarn buildClient", "buildClient": "cd webapp && yarn && yarn build && cd ..", "prepare": "yarn build" @@ -35,19 +36,22 @@ "mem": "^5.1.1", "mongoose": "5.6.6", "nodemailer": "^6.3.0", - "oauth2-server": "^3.0.1", + "oauth2-server": "^2.4.1", "redux-thunk": "^2.3.0", "saml-idp": "^1.1.0", "tslib": "1.10.0" }, "devDependencies": { + "@steedos/meteor-bundle-runner": "^1.16.4", "@steedos/objectql": "^1.16.2", + "@steedos/steedos-plugin-workflow": "^2.0.4", "@types/dotenv-flow": "^3.0.0", "@types/node": "12.6.8", "cross-env": "^5.2.0", "dotenv": "^8.2.0", "dotenv-flow": "^3.1.0", "nodemon": "1.19.1", + "steedos-server": "^1.16.4", "ts-node": "8.3.0", "typescript": "3.5.3" }, diff --git a/packages/accounts/steedos-server.ts b/packages/accounts/steedos-server.ts new file mode 100644 index 0000000000..1bb633d73d --- /dev/null +++ b/packages/accounts/steedos-server.ts @@ -0,0 +1,40 @@ +require('dotenv-flow').config(); + +import * as express from 'express'; +import * as hbs from 'hbs'; +import * as path from 'path'; +import * as bodyParser from 'body-parser'; +import * as cors from 'cors'; +import { init } from "./src"; + +var server = require('@steedos/meteor-bundle-runner'); +var steedos = require('@steedos/core') +server.Fiber(function () { + try { + server.Profile.run("Server startup", function () { + server.loadServerBundles(); + steedos.init(); + + const app = express(); + app.engine('handlebars', hbs.__express); + app.set('views', __dirname + '/src/saml-idp/views'); + app.set('view engine', 'hbs'); + app.set('view options', { layout: 'layout' }) + app.use(bodyParser.json()); + app.use(bodyParser.urlencoded({ extended: true })); + app.use(cors({origin: true, credentials: true})); + + app.get('/', (req, res) => { + res.redirect("/accounts/a"); + res.end(); + }); + + init({app}); + + server.callStartupHooks(); + server.runMain(); + }) + } catch (error) { + console.error(error.stack) + } +}).run() diff --git a/packages/accounts/yarn.lock b/packages/accounts/yarn.lock index b31a351568..814a90cada 100644 Binary files a/packages/accounts/yarn.lock and b/packages/accounts/yarn.lock differ