Commit ee40c4b1 authored by Jure's avatar Jure

feat: split server and client and introduce typescript support

parent 284bebb5
Pipeline #13078 failed with stages
in 2 minutes and 33 seconds
**/_build
**/dist
**/node_modules
**/coverage
......@@ -86,7 +86,8 @@ api/db/*
.wallaby.js
logs
.env.*
_build
client/dist
server/dist
coverage/
yarn-error.log
package-lock.json
......
const logger = require('@pubsweet/logger')
const startServer = require('pubsweet-server')
startServer().catch(err => {
logger.error('FATAL ERROR, SHUTTING DOWN:', err)
process.exit(1)
})
......@@ -3,5 +3,6 @@
"@pubsweet/model-team",
"@pubsweet/model-blog",
"@pubsweet/model-blogpost",
"@pubsweet/component-password-reset-server"
"@pubsweet/component-password-reset-server",
"@pubsweet/job-xsweet"
]
......@@ -5,7 +5,7 @@ const components = require('./components.json')
module.exports = {
'pubsweet-server': {
db: {
database: 'starter',
database: 'test',
},
logger,
port: 3000,
......
......@@ -13,14 +13,15 @@
"@pubsweet/coko-theme": "^5.1.0",
"@pubsweet/component-password-reset-client": "^3.0.7",
"@pubsweet/component-password-reset-server": "^2.0.3",
"@pubsweet/db-manager": "3.0.4",
"@pubsweet/default-theme": "4.0.13",
"@pubsweet/db-manager": "3.0.9",
"@pubsweet/default-theme": "4.1.2",
"@pubsweet/job-xsweet": "^1.2.7",
"@pubsweet/logger": "^0.2.18",
"@pubsweet/model-blog": "^0.0.11",
"@pubsweet/model-blogpost": "^0.0.11",
"@pubsweet/model-blog": "^0.0.16",
"@pubsweet/model-blogpost": "^0.0.16",
"@pubsweet/model-team": "^2.0.5",
"@pubsweet/model-user": "^4.0.5",
"@pubsweet/models": "0.2.5",
"@pubsweet/models": "0.2.10",
"@pubsweet/ui": "^10.2.0",
"authsome": "^0.1.0",
"mini-css-extract-plugin": "^0.5.0",
......@@ -80,16 +81,20 @@
"style-loader": "^0.23.1",
"testcafe": "^0.23.3",
"testcafe-react-selectors": "^3.0.0",
"ts-node-dev": "^1.0.0-pre.40",
"typescript": "^3.5.3",
"url-loader": "^1.1.2",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.6",
"webpack-dev-server": "^3.7.2",
"webpack-hot-middleware": "^2.22.1"
},
"scripts": {
"lint": "eslint --ext js,jsx app config test webpack",
"start": "docker-compose up",
"server": "pubsweet server",
"start:services": "docker-compose up db",
"setupdb": "pubsweet setupdb",
"start:client": "webpack-dev-server --config webpack/webpack.development.config.js",
"start:server": "ts-node-dev -P tsconfig.server.js server/start.ts",
"seed": "node scripts/seed.js",
"precommit": "lint-staged",
"test": "NODE_ENV=test NODE_PRESERVE_SYMLINKS=1 testcafe chrome 'test/**/*.test.js'"
......
const { startServer } = require('pubsweet-server')
startServer()
{
"extends": "./tsconfig.json",
"exclude": ["server/"]
}
{
"compilerOptions": {
"module": "commonjs",
// "declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./server/dist",
"baseUrl": "./",
"allowJs": true,
"incremental": true
}
// "exclude": ["node_modules"]
}
{
"extends": "./tsconfig.json",
"exclude": ["client/", "server/dist/"]
}
const path = require('path')
const config = require('config')
const webpack = require('webpack')
......@@ -17,8 +16,8 @@ module.exports = (opts = {}) => {
if (opts.html) {
plugins.push(
new HtmlWebpackPlugin({
title: 'PubSweet app',
template: '../app/index.ejs', // Load a custom template
title: 'PubSweet Starter App',
template: '../client/index.ejs', // Load a custom template
inject: 'body', // Inject all scripts into the body
}),
)
......@@ -60,27 +59,5 @@ module.exports = (opts = {}) => {
new CompressionPlugin(),
)
// These replacements are necessary until Atlaskit
// doesn't update to styled-components v4
plugins.push(
new webpack.NormalModuleReplacementPlugin(
/@atlaskit\/media-ui\/mixins.js/,
path.join(
__dirname,
'../app/components/CollabEditor/src/media-ui-mixins.js',
),
),
)
plugins.push(
new webpack.NormalModuleReplacementPlugin(
/@atlaskit\/editor-core\/plugins\/gap-cursor\/styles.js/,
path.join(
__dirname,
'../app/components/CollabEditor/src/gap-cursor-styles.js',
),
),
)
return plugins
}
......@@ -4,30 +4,38 @@ const config = require('config')
const { pick } = require('lodash')
const rules = require('./common-rules')
const outputPath = path.resolve(__dirname, '..', '_build', 'assets')
const contentBase = path.resolve(__dirname, '..', 'client', 'dist')
// can't use node-config in webpack so save whitelisted client config into the build and alias it below
const clientConfig = pick(config, config.publicKeys)
fs.ensureDirSync(outputPath)
const clientConfigPath = path.join(outputPath, 'client-config.json')
fs.ensureDirSync(contentBase)
const clientConfigPath = path.join(contentBase, 'client-config.json')
fs.writeJsonSync(clientConfigPath, clientConfig, { spaces: 2 })
const plugins = require('./plugins')
module.exports = [
{
// The configuration for the client
name: 'app',
devServer: {
port: 9000,
hot: true,
contentBase,
proxy: {
'/api': 'http://localhost:3000',
'/graphql': 'http://localhost:3000',
},
historyApiFallback: true,
},
name: 'client application',
target: 'web',
mode: 'development',
context: path.join(__dirname, '..', 'app'),
context: path.join(__dirname, '..', 'client'),
entry: {
app: ['react-hot-loader/patch', 'webpack-hot-middleware/client', './app'],
},
output: {
path: outputPath,
path: contentBase,
filename: '[name].js',
publicPath: '/assets/',
},
devtool: 'cheap-module-source-map',
module: {
......@@ -43,7 +51,7 @@ module.exports = [
},
plugins: plugins({
hmr: true,
html: false,
html: true,
noEmitOnErrors: true,
extractText: false,
optimize: true,
......
......@@ -4,7 +4,7 @@ const config = require('config')
const { pick } = require('lodash')
const rules = require('./common-rules')
const outputPath = path.resolve(__dirname, '..', '_build', 'assets')
const outputPath = path.resolve(__dirname, '..', 'client', 'dist')
// can't use node-config in webpack so save whitelisted client config into the build and alias it below
const clientConfig = pick(config, config.publicKeys)
......@@ -17,17 +17,16 @@ const plugins = require('./plugins')
module.exports = [
{
// The configuration for the client
name: 'app',
name: 'client application',
mode: 'production',
target: 'web',
context: path.join(__dirname, '..', 'app'),
context: path.join(__dirname, '..', 'client'),
entry: {
app: ['./app'],
app: ['./client'],
},
output: {
path: outputPath,
filename: '[name].[hash].js',
publicPath: '/assets/',
},
module: {
rules,
......
......@@ -4,7 +4,7 @@ const config = require('config')
const { pick } = require('lodash')
const rules = require('./common-rules')
const outputPath = path.resolve(__dirname, '..', '_build', 'assets')
const outputPath = path.resolve(__dirname, '..', 'client', 'dist')
// can't use node-config in webpack so save whitelisted client config into the build and alias it below
const clientConfig = pick(config, config.publicKeys)
......@@ -17,17 +17,20 @@ const plugins = require('./plugins')
module.exports = [
{
// The configuration for the client
name: 'app',
name: 'client application',
mode: 'development',
target: 'web',
context: path.join(__dirname, '..', 'app'),
context: path.join(__dirname, '..', 'client'),
entry: {
app: ['react-hot-loader/patch', 'webpack-hot-middleware/client', './app'],
app: [
'react-hot-loader/patch',
'webpack-hot-middleware/client',
'./client',
],
},
output: {
path: outputPath,
filename: '[name].js',
publicPath: '/assets/',
},
module: {
rules,
......@@ -42,7 +45,7 @@ module.exports = [
},
plugins: plugins({
hmr: true,
html: false,
html: true,
noEmitOnErrors: true,
extractText: false,
optimize: true,
......
......@@ -976,22 +976,6 @@
http-status-codes "^1.3.0"
passport "^0.4.0"
"@pubsweet/model-user@^4.0.5":
version "4.0.5"
resolved "https://registry.yarnpkg.com/@pubsweet/model-user/-/model-user-4.0.5.tgz#65910f167f2364f39493b8e6de138734ccd20136"
integrity sha512-vC7+oa2R9BQNPPZ5R1RaSG3un5Z1tgaW2ICSav9Afw3ClJF0AfbhtgqIlquOUMoTlc7WuS+pqyYsRYkGDG9a8w==
dependencies:
"@pubsweet/base-model" "^3.0.5"
"@pubsweet/errors" "^2.0.8"
"@pubsweet/logger" "^0.2.18"
bcrypt "3.0.2"
http-status-codes "^1.3.0"
jsonwebtoken "^8.4.0"
passport "^0.4.0"
passport-anonymous "^1.0.1"
passport-http-bearer "^1.0.1"
passport-local "^1.0.0"
"@pubsweet/models@0.2.5", "@pubsweet/models@^0.2.5":
version "0.2.5"
resolved "https://registry.yarnpkg.com/@pubsweet/models/-/models-0.2.5.tgz#3fa493157d5d95c466b6cc5bf4ead7381c8ff5a1"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment