add typescript support to worker
This commit is contained in:
parent
000d2c5ad4
commit
8fa522cff0
|
@ -3,10 +3,11 @@
|
||||||
"emit": true,
|
"emit": true,
|
||||||
"key": true
|
"key": true
|
||||||
},
|
},
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
"env": {
|
"env": {
|
||||||
"node": true
|
"node": true
|
||||||
},
|
},
|
||||||
"extends": ["eslint:recommended"],
|
"extends": ["eslint:recommended"],
|
||||||
"rules": {
|
"rules": {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
{
|
{
|
||||||
"watch": ["src", "../auth"]
|
"watch": ["src", "../auth"],
|
||||||
}
|
"ext": "js,ts,json",
|
||||||
|
"ignore": ["src/**/*.spec.ts", "src/**/*.spec.js"],
|
||||||
|
"exec": "ts-node src/index.ts"
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"email": "hi@budibase.com",
|
"email": "hi@budibase.com",
|
||||||
"version": "1.0.44-alpha.6",
|
"version": "1.0.44-alpha.6",
|
||||||
"description": "Budibase background service",
|
"description": "Budibase background service",
|
||||||
"main": "src/index.js",
|
"main": "src/index.ts",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Budibase/budibase.git"
|
"url": "https://github.com/Budibase/budibase.git"
|
||||||
|
@ -12,10 +12,15 @@
|
||||||
"budibase"
|
"budibase"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"run:docker": "node src/index.js",
|
"build": "rimraf dist/ && tsc",
|
||||||
|
"postbuild": "copyfiles -u 1 src/**/*.hbs dist/",
|
||||||
|
"run:docker": "node dist/index.js",
|
||||||
"build:docker": "docker build . -t worker-service --label version=$BUDIBASE_RELEASE_VERSION",
|
"build:docker": "docker build . -t worker-service --label version=$BUDIBASE_RELEASE_VERSION",
|
||||||
"dev:stack:init": "node ./scripts/dev/manage.js init",
|
"dev:stack:init": "node ./scripts/dev/manage.js init",
|
||||||
"dev:builder": "npm run dev:stack:init && nodemon",
|
"dev:builder": "npm run dev:stack:init && nodemon",
|
||||||
|
"format": "prettier --config ../../.prettierrc.json 'src/**/*.ts' --write",
|
||||||
|
"lint": "eslint --fix src/",
|
||||||
|
"lint:fix": "yarn run format && yarn run lint",
|
||||||
"test": "jest --runInBand",
|
"test": "jest --runInBand",
|
||||||
"env:multi:enable": "node scripts/multiTenancy.js enable",
|
"env:multi:enable": "node scripts/multiTenancy.js enable",
|
||||||
"env:multi:disable": "node scripts/multiTenancy.js disable",
|
"env:multi:disable": "node scripts/multiTenancy.js disable",
|
||||||
|
@ -58,14 +63,26 @@
|
||||||
"server-destroy": "^1.0.1"
|
"server-destroy": "^1.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jest": "^26.6.3",
|
"@types/jest": "^26.0.23",
|
||||||
|
"@types/koa": "^2.13.3",
|
||||||
|
"@types/koa-router": "^7.4.2",
|
||||||
|
"@types/node": "^15.12.4",
|
||||||
|
"@typescript-eslint/parser": "4.28.0",
|
||||||
|
"copyfiles": "^2.4.1",
|
||||||
|
"eslint": "^6.8.0",
|
||||||
|
"jest": "^27.0.5",
|
||||||
"nodemon": "^2.0.7",
|
"nodemon": "^2.0.7",
|
||||||
"pouchdb-adapter-memory": "^7.2.2",
|
"pouchdb-adapter-memory": "^7.2.2",
|
||||||
|
"prettier": "2.3.1",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
"supertest": "^6.1.3",
|
"supertest": "^6.1.3",
|
||||||
"typescript": "^4.5.4",
|
"ts-jest": "^27.0.3",
|
||||||
|
"ts-node": "^10.0.0",
|
||||||
|
"typescript": "4.3.5",
|
||||||
"update-dotenv": "^1.1.1"
|
"update-dotenv": "^1.1.1"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
|
"preset": "ts-jest",
|
||||||
"testEnvironment": "node",
|
"testEnvironment": "node",
|
||||||
"setupFiles": [
|
"setupFiles": [
|
||||||
"./scripts/jestSetup.js"
|
"./scripts/jestSetup.js"
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
// need to load environment first
|
// need to load environment first
|
||||||
|
import { Scope } from "@sentry/node"
|
||||||
|
import { Event } from "@sentry/types/dist/event"
|
||||||
|
import Application from "koa"
|
||||||
|
|
||||||
const env = require("./environment")
|
const env = require("./environment")
|
||||||
const CouchDB = require("./db")
|
const CouchDB = require("./db")
|
||||||
require("@budibase/backend-core").init(CouchDB)
|
require("@budibase/backend-core").init(CouchDB)
|
||||||
|
@ -13,7 +17,7 @@ const api = require("./api")
|
||||||
const redis = require("./utilities/redis")
|
const redis = require("./utilities/redis")
|
||||||
const Sentry = require("@sentry/node")
|
const Sentry = require("@sentry/node")
|
||||||
|
|
||||||
const app = new Koa()
|
const app: Application = new Koa()
|
||||||
|
|
||||||
app.keys = ["secret", "key"]
|
app.keys = ["secret", "key"]
|
||||||
|
|
||||||
|
@ -42,8 +46,8 @@ if (env.isProd()) {
|
||||||
Sentry.init()
|
Sentry.init()
|
||||||
|
|
||||||
app.on("error", (err, ctx) => {
|
app.on("error", (err, ctx) => {
|
||||||
Sentry.withScope(function (scope) {
|
Sentry.withScope(function (scope: Scope) {
|
||||||
scope.addEventProcessor(function (event) {
|
scope.addEventProcessor(function (event: Event) {
|
||||||
return Sentry.Handlers.parseRequest(event, ctx.request)
|
return Sentry.Handlers.parseRequest(event, ctx.request)
|
||||||
})
|
})
|
||||||
Sentry.captureException(err)
|
Sentry.captureException(err)
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue