Skip to content

Commit

Permalink
chore(backend): use shared folder
Browse files Browse the repository at this point in the history
  • Loading branch information
lamkeewei committed Apr 20, 2021
1 parent 5ba3e19 commit e0c461e
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 6,200 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Expand Up @@ -15,8 +15,10 @@ jobs:
- cd $TRAVIS_BUILD_DIR/backend
- npx lockfile-lint --type npm --path package-lock.json -o "https:" -o "file:" --allowed-hosts npm
install:
- npm ci
- cd $TRAVIS_BUILD_DIR/shared && npm ci
- cd $TRAVIS_BUILD_DIR/backend && npm ci
script:
- npm run build
- npm run lint-no-fix
- npm run test
before_deploy:
Expand Down
3 changes: 2 additions & 1 deletion backend/Dockerfile
Expand Up @@ -12,7 +12,8 @@ RUN aws configure set default.region ap-southeast-1

WORKDIR /usr/home/postmangovsg

COPY modules ../modules
COPY shared ../shared
RUN cd ../shared && npm ci && cd ../postmangovsg

COPY ./package* ./
RUN npm ci
Expand Down
2 changes: 1 addition & 1 deletion backend/before-deploy.sh
@@ -1,7 +1,7 @@
#!/bin/bash

# Copy local module
cp -R ../modules ./
cp -R ../shared ./
# Replace the secret id according to the right branch
# Using '#' as a delimiter for SED instead of '/'
# '/' will clash with secret id names, eg: 'staging/eb/postmangovsg-staging-40ffadb'
Expand Down
6,185 changes: 0 additions & 6,185 deletions backend/package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions backend/package.json
Expand Up @@ -4,7 +4,7 @@
"description": "Backend / API server for Postman",
"main": "build/server.js",
"scripts": {
"build": "rimraf build && tsc",
"build": "rimraf build && tsc --build",
"dev": "npm run postbuild && tsc-watch --onSuccess \"node ./build/server.js\"",
"lint-no-fix": "tsc --noEmit && eslint --ext .js,.ts --cache .",
"lint": "npm run lint-no-fix -- --fix",
Expand Down Expand Up @@ -45,7 +45,6 @@
"papaparse": "^5.2.0",
"pg": "^8.5.1",
"pg-connection-string": "^2.4.0",
"postman-templating": "file:../modules/postman-templating",
"redis": "^3.0.2",
"reflect-metadata": "^0.1.13",
"sequelize": "^5.22.4",
Expand Down Expand Up @@ -105,7 +104,8 @@
"@core": "build/core",
"@sms": "build/sms",
"@email": "build/email",
"@telegram": "build/telegram"
"@telegram": "build/telegram",
"@shared": "../shared/build/"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion backend/src/core/services/protected.service.ts
@@ -1,6 +1,6 @@
import { Transaction } from 'sequelize'
import { difference } from 'lodash'
import { TemplateClient, XSS_EMAIL_OPTION } from 'postman-templating'
import { TemplateClient, XSS_EMAIL_OPTION } from '@shared/templating'

import { ProtectedMessage, Campaign } from '@core/models'
import config from '@core/config'
Expand Down
2 changes: 1 addition & 1 deletion backend/src/email/middlewares/email-template.middleware.ts
Expand Up @@ -7,7 +7,7 @@ import {
InvalidRecipientError,
UserError,
} from '@core/errors'
import { TemplateError } from 'postman-templating'
import { TemplateError } from '@shared/templating'
import {
AuthService,
UploadService,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/email/services/email-template.service.ts
Expand Up @@ -7,7 +7,7 @@ import {
TemplateClient,
XSS_EMAIL_OPTION,
TemplateError,
} from 'postman-templating'
} from '@shared/templating'

import { EmailTemplate, EmailMessage } from '@email/models'
import { StoreTemplateInput, StoreTemplateOutput } from '@email/interfaces'
Expand Down
2 changes: 1 addition & 1 deletion backend/src/sms/middlewares/sms-template.middleware.ts
Expand Up @@ -8,7 +8,7 @@ import {
InvalidRecipientError,
UserError,
} from '@core/errors'
import { TemplateError } from 'postman-templating'
import { TemplateError } from '@shared/templating'
import { UploadService, StatsService, ParseCsvService } from '@core/services'
import { SmsTemplateService, SmsService } from '@sms/services'
import { StoreTemplateOutput } from '@sms/interfaces'
Expand Down
2 changes: 1 addition & 1 deletion backend/src/sms/services/sms-template.service.ts
Expand Up @@ -7,7 +7,7 @@ import {
TemplateClient,
XSS_SMS_OPTION,
TemplateError,
} from 'postman-templating'
} from '@shared/templating'

import { SmsTemplate, SmsMessage } from '@sms/models'
import { StoreTemplateInput, StoreTemplateOutput } from '@sms/interfaces'
Expand Down
Expand Up @@ -9,7 +9,7 @@ import {
InvalidRecipientError,
UserError,
} from '@core/errors'
import { TemplateError } from 'postman-templating'
import { TemplateError } from '@shared/templating'
import { UploadService, StatsService, ParseCsvService } from '@core/services'
import { Campaign } from '@core/models'
import { TelegramService, TelegramTemplateService } from '@telegram/services'
Expand Down
2 changes: 1 addition & 1 deletion backend/src/telegram/services/telegram-template.service.ts
Expand Up @@ -9,7 +9,7 @@ import {
TemplateClient,
XSS_TELEGRAM_OPTION,
TemplateError,
} from 'postman-templating'
} from '@shared/templating'

import { TelegramMessage, TelegramTemplate } from '@telegram/models'
import { StoreTemplateInput, StoreTemplateOutput } from '@telegram/interfaces'
Expand Down
8 changes: 6 additions & 2 deletions backend/tsconfig.json
@@ -1,13 +1,16 @@
{
"include": [
"./src/**/*"
"src"
],
"exclude": [
"node_modules"
],
"files": [
"./src/server.ts"
],
"references": [
{ "path": "../shared" }
],
"compileOnSave": true,
"compilerOptions": {
"target": "es6",
Expand Down Expand Up @@ -35,7 +38,8 @@
"@core/*": ["core/*"],
"@sms/*": ["sms/*"],
"@email/*": ["email/*"],
"@telegram/*": ["telegram/*"]
"@telegram/*": ["telegram/*"],
"@shared/*": ["../../shared/src/*"]
},
"esModuleInterop": true,
"experimentalDecorators": true,
Expand Down

0 comments on commit e0c461e

Please sign in to comment.