feat: switch to tsx (typescript execute)

This commit is contained in:
diced 2022-07-28 11:30:14 -07:00
parent 3ea24ddf0c
commit cdcb31130b
No known key found for this signature in database
GPG key ID: 370BD1BA142842D1
4 changed files with 314 additions and 20 deletions

View file

@ -61,4 +61,4 @@ COPY --from=builder /build/tsconfig.json ./tsconfig.json
COPY --from=builder /build/package.json ./package.json
COPY --from=builder /build/mimes.json ./mimes.json
CMD ["node", "dist/server"]
CMD ["node_modules/.bin/tsx", "src/server"]

View file

@ -3,13 +3,12 @@
"version": "3.4.8",
"license": "MIT",
"scripts": {
"dev": "node esbuild.config.js && REACT_EDITOR=code NODE_ENV=development node --enable-source-maps dist/server",
"build": "npm-run-all build:server build:schema build:next",
"build:server": "node esbuild.config.js",
"dev": "REACT_EDITOR=code NODE_ENV=development tsx src/server",
"build": "npm-run-all build:schema build:next",
"build:next": "next build",
"build:schema": "prisma generate --schema=prisma/schema.prisma",
"migrate:dev": "prisma migrate dev --create-only",
"start": "node dist/server",
"start": "tsx src/server",
"lint": "next lint",
"docker:run": "docker-compose up -d",
"docker:down": "docker-compose down",
@ -63,6 +62,7 @@
"eslint-config-next": "12.1.6",
"npm-run-all": "^4.1.5",
"ts-node": "^10.8.1",
"tsx": "^3.8.0",
"typescript": "^4.7.3"
},
"repository": {

View file

@ -6,30 +6,20 @@ import { createServer, IncomingMessage, OutgoingMessage, ServerResponse } from '
import { extname } from 'path';
import { mkdir } from 'fs/promises';
import { getStats, log, migrations } from './util';
import Logger from '../lib/logger';
import { guess } from '../lib/mimes';
import exts from '../lib/exts';
import Logger from 'lib/logger';
import { guess } from 'lib/mimes';
import exts from 'lib/exts';
import { version } from '../../package.json';
import type { Config } from 'lib/config/Config';
import type { Datasource } from 'lib/datasources';
import config from 'lib/config';
import datasource from 'lib/datasource';
const dev = process.env.NODE_ENV === 'development';
let config: Config, datasource: Datasource;
const logger = Logger.get('server');
logger.info(`starting ${process.env.NODE_ENV || 'production'} zipline@${version} server`);
start();
async function start() {
const c = await import('../lib/config.js');
// @ts-ignore
config = c.default.default;
const d = await import('../lib/datasource.js');
// @ts-ignore
datasource = d.default.default;
// annoy user if they didnt change secret from default "changethis"
if (config.core.secret === 'changethis') {
logger.error('Secret is not set!');
@ -121,6 +111,8 @@ async function start() {
});
http.listen(config.core.port, config.core.host ?? '0.0.0.0');
logger.info(`started ${dev ? 'development' : 'production'} zipline@${version} server`);
stats(prisma);
}

302
yarn.lock
View file

@ -441,6 +441,36 @@ __metadata:
languageName: node
linkType: hard
"@esbuild-kit/cjs-loader@npm:^2.3.1":
version: 2.3.2
resolution: "@esbuild-kit/cjs-loader@npm:2.3.2"
dependencies:
"@esbuild-kit/core-utils": ^2.1.0
get-tsconfig: ^4.1.0
checksum: ade4e17ab9f4951f812c73d67de7f1815607303bee765191a5c23457ac370c342326aaf08070c94de875ae1fc8b26a940967c6f64e49ae4f640af106ae2a21f8
languageName: node
linkType: hard
"@esbuild-kit/core-utils@npm:^2.1.0":
version: 2.1.0
resolution: "@esbuild-kit/core-utils@npm:2.1.0"
dependencies:
esbuild: ~0.14.47
source-map-support: ^0.5.21
checksum: 6c55564aab599e6232f581a8ed45ee9d3cb4877667ad0831cdde6e474496cdf8f2fc8310a27f1f4e1eb087fe7edf80196c5fa9c7714ef6cafc095b162cf06d80
languageName: node
linkType: hard
"@esbuild-kit/esm-loader@npm:^2.4.1":
version: 2.4.2
resolution: "@esbuild-kit/esm-loader@npm:2.4.2"
dependencies:
"@esbuild-kit/core-utils": ^2.1.0
get-tsconfig: ^4.1.0
checksum: 3801950445ef04dcf787651705126bb798bea8b8df57a809a7dec8f5533fdcc69916e10d6d51542d0deb6a17089fd243cd4a286f4f41790221b232b9e851a1a4
languageName: node
linkType: hard
"@eslint/eslintrc@npm:^0.4.3":
version: 0.4.3
resolution: "@eslint/eslintrc@npm:0.4.3"
@ -3203,6 +3233,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-android-64@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-android-64@npm:0.14.51"
conditions: os=android & cpu=x64
languageName: node
linkType: hard
"esbuild-android-arm64@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-android-arm64@npm:0.14.50"
@ -3210,6 +3247,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-android-arm64@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-android-arm64@npm:0.14.51"
conditions: os=android & cpu=arm64
languageName: node
linkType: hard
"esbuild-darwin-64@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-darwin-64@npm:0.14.50"
@ -3217,6 +3261,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-darwin-64@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-darwin-64@npm:0.14.51"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard
"esbuild-darwin-arm64@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-darwin-arm64@npm:0.14.50"
@ -3224,6 +3275,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-darwin-arm64@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-darwin-arm64@npm:0.14.51"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard
"esbuild-freebsd-64@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-freebsd-64@npm:0.14.50"
@ -3231,6 +3289,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-freebsd-64@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-freebsd-64@npm:0.14.51"
conditions: os=freebsd & cpu=x64
languageName: node
linkType: hard
"esbuild-freebsd-arm64@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-freebsd-arm64@npm:0.14.50"
@ -3238,6 +3303,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-freebsd-arm64@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-freebsd-arm64@npm:0.14.51"
conditions: os=freebsd & cpu=arm64
languageName: node
linkType: hard
"esbuild-linux-32@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-linux-32@npm:0.14.50"
@ -3245,6 +3317,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-32@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-linux-32@npm:0.14.51"
conditions: os=linux & cpu=ia32
languageName: node
linkType: hard
"esbuild-linux-64@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-linux-64@npm:0.14.50"
@ -3252,6 +3331,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-64@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-linux-64@npm:0.14.51"
conditions: os=linux & cpu=x64
languageName: node
linkType: hard
"esbuild-linux-arm64@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-linux-arm64@npm:0.14.50"
@ -3259,6 +3345,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-arm64@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-linux-arm64@npm:0.14.51"
conditions: os=linux & cpu=arm64
languageName: node
linkType: hard
"esbuild-linux-arm@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-linux-arm@npm:0.14.50"
@ -3266,6 +3359,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-arm@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-linux-arm@npm:0.14.51"
conditions: os=linux & cpu=arm
languageName: node
linkType: hard
"esbuild-linux-mips64le@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-linux-mips64le@npm:0.14.50"
@ -3273,6 +3373,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-mips64le@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-linux-mips64le@npm:0.14.51"
conditions: os=linux & cpu=mips64el
languageName: node
linkType: hard
"esbuild-linux-ppc64le@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-linux-ppc64le@npm:0.14.50"
@ -3280,6 +3387,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-ppc64le@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-linux-ppc64le@npm:0.14.51"
conditions: os=linux & cpu=ppc64
languageName: node
linkType: hard
"esbuild-linux-riscv64@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-linux-riscv64@npm:0.14.50"
@ -3287,6 +3401,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-riscv64@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-linux-riscv64@npm:0.14.51"
conditions: os=linux & cpu=riscv64
languageName: node
linkType: hard
"esbuild-linux-s390x@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-linux-s390x@npm:0.14.50"
@ -3294,6 +3415,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-s390x@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-linux-s390x@npm:0.14.51"
conditions: os=linux & cpu=s390x
languageName: node
linkType: hard
"esbuild-netbsd-64@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-netbsd-64@npm:0.14.50"
@ -3301,6 +3429,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-netbsd-64@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-netbsd-64@npm:0.14.51"
conditions: os=netbsd & cpu=x64
languageName: node
linkType: hard
"esbuild-openbsd-64@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-openbsd-64@npm:0.14.50"
@ -3308,6 +3443,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-openbsd-64@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-openbsd-64@npm:0.14.51"
conditions: os=openbsd & cpu=x64
languageName: node
linkType: hard
"esbuild-sunos-64@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-sunos-64@npm:0.14.50"
@ -3315,6 +3457,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-sunos-64@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-sunos-64@npm:0.14.51"
conditions: os=sunos & cpu=x64
languageName: node
linkType: hard
"esbuild-windows-32@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-windows-32@npm:0.14.50"
@ -3322,6 +3471,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-windows-32@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-windows-32@npm:0.14.51"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard
"esbuild-windows-64@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-windows-64@npm:0.14.50"
@ -3329,6 +3485,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-windows-64@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-windows-64@npm:0.14.51"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
"esbuild-windows-arm64@npm:0.14.50":
version: 0.14.50
resolution: "esbuild-windows-arm64@npm:0.14.50"
@ -3336,6 +3499,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-windows-arm64@npm:0.14.51":
version: 0.14.51
resolution: "esbuild-windows-arm64@npm:0.14.51"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard
"esbuild@npm:^0.14.44":
version: 0.14.50
resolution: "esbuild@npm:0.14.50"
@ -3407,6 +3577,77 @@ __metadata:
languageName: node
linkType: hard
"esbuild@npm:~0.14.47":
version: 0.14.51
resolution: "esbuild@npm:0.14.51"
dependencies:
esbuild-android-64: 0.14.51
esbuild-android-arm64: 0.14.51
esbuild-darwin-64: 0.14.51
esbuild-darwin-arm64: 0.14.51
esbuild-freebsd-64: 0.14.51
esbuild-freebsd-arm64: 0.14.51
esbuild-linux-32: 0.14.51
esbuild-linux-64: 0.14.51
esbuild-linux-arm: 0.14.51
esbuild-linux-arm64: 0.14.51
esbuild-linux-mips64le: 0.14.51
esbuild-linux-ppc64le: 0.14.51
esbuild-linux-riscv64: 0.14.51
esbuild-linux-s390x: 0.14.51
esbuild-netbsd-64: 0.14.51
esbuild-openbsd-64: 0.14.51
esbuild-sunos-64: 0.14.51
esbuild-windows-32: 0.14.51
esbuild-windows-64: 0.14.51
esbuild-windows-arm64: 0.14.51
dependenciesMeta:
esbuild-android-64:
optional: true
esbuild-android-arm64:
optional: true
esbuild-darwin-64:
optional: true
esbuild-darwin-arm64:
optional: true
esbuild-freebsd-64:
optional: true
esbuild-freebsd-arm64:
optional: true
esbuild-linux-32:
optional: true
esbuild-linux-64:
optional: true
esbuild-linux-arm:
optional: true
esbuild-linux-arm64:
optional: true
esbuild-linux-mips64le:
optional: true
esbuild-linux-ppc64le:
optional: true
esbuild-linux-riscv64:
optional: true
esbuild-linux-s390x:
optional: true
esbuild-netbsd-64:
optional: true
esbuild-openbsd-64:
optional: true
esbuild-sunos-64:
optional: true
esbuild-windows-32:
optional: true
esbuild-windows-64:
optional: true
esbuild-windows-arm64:
optional: true
bin:
esbuild: bin/esbuild
checksum: 0fa8a52dd1dc7b231f7b02448aae5ee71ff2fe26ee67f6c97945a6dd128806be6eb2c73be7b49c7b25f831d646edd3da245faf31ede136f4aa0934abd7206e4b
languageName: node
linkType: hard
"escape-string-regexp@npm:4.0.0, escape-string-regexp@npm:^4.0.0":
version: 4.0.0
resolution: "escape-string-regexp@npm:4.0.0"
@ -4019,6 +4260,25 @@ __metadata:
languageName: node
linkType: hard
"fsevents@npm:~2.3.2":
version: 2.3.2
resolution: "fsevents@npm:2.3.2"
dependencies:
node-gyp: latest
checksum: 97ade64e75091afee5265e6956cb72ba34db7819b4c3e94c431d4be2b19b8bb7a2d4116da417950c3425f17c8fe693d25e20212cac583ac1521ad066b77ae31f
conditions: os=darwin
languageName: node
linkType: hard
"fsevents@patch:fsevents@~2.3.2#~builtin<compat/fsevents>":
version: 2.3.2
resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin<compat/fsevents>::version=2.3.2&hash=18f3a7"
dependencies:
node-gyp: latest
conditions: os=darwin
languageName: node
linkType: hard
"function-bind@npm:^1.1.1":
version: 1.1.1
resolution: "function-bind@npm:1.1.1"
@ -4120,6 +4380,13 @@ __metadata:
languageName: node
linkType: hard
"get-tsconfig@npm:^4.1.0":
version: 4.2.0
resolution: "get-tsconfig@npm:4.2.0"
checksum: dfae3520bee20b71a651fdc93fd29901013dfc4df9fb41a423cf3efb4468c79087ef9d3bc3d0625b6486397730991d2a749eed4985d8ab411f481319c3e931e5
languageName: node
linkType: hard
"glob-parent@npm:^5.1.2":
version: 5.1.2
resolution: "glob-parent@npm:5.1.2"
@ -7283,6 +7550,16 @@ __metadata:
languageName: node
linkType: hard
"source-map-support@npm:^0.5.21":
version: 0.5.21
resolution: "source-map-support@npm:0.5.21"
dependencies:
buffer-from: ^1.0.0
source-map: ^0.6.0
checksum: 43e98d700d79af1d36f859bdb7318e601dfc918c7ba2e98456118ebc4c4872b327773e5a1df09b0524e9e5063bb18f0934538eace60cca2710d1fa687645d137
languageName: node
linkType: hard
"source-map@npm:^0.5.7":
version: 0.5.7
resolution: "source-map@npm:0.5.7"
@ -7290,6 +7567,13 @@ __metadata:
languageName: node
linkType: hard
"source-map@npm:^0.6.0":
version: 0.6.1
resolution: "source-map@npm:0.6.1"
checksum: 59ce8640cf3f3124f64ac289012c2b8bd377c238e316fb323ea22fbfe83da07d81e000071d7242cad7a23cd91c7de98e4df8830ec3f133cb6133a5f6e9f67bc2
languageName: node
linkType: hard
"spdx-correct@npm:^3.0.0":
version: 3.1.1
resolution: "spdx-correct@npm:3.1.1"
@ -7857,6 +8141,23 @@ __metadata:
languageName: node
linkType: hard
"tsx@npm:^3.8.0":
version: 3.8.0
resolution: "tsx@npm:3.8.0"
dependencies:
"@esbuild-kit/cjs-loader": ^2.3.1
"@esbuild-kit/core-utils": ^2.1.0
"@esbuild-kit/esm-loader": ^2.4.1
fsevents: ~2.3.2
dependenciesMeta:
fsevents:
optional: true
bin:
tsx: dist/cli.js
checksum: 2990425ad04aa5a1bb7ad1c7dc054fe97d56b22cfbc840a3c65417c7c73bec6274bbcb29c46dfc5b1f386b68144c37df0c413e277c0218b3162c8768ddb61778
languageName: node
linkType: hard
"tunnel@npm:^0.0.6":
version: 0.0.6
resolution: "tunnel@npm:0.0.6"
@ -8385,6 +8686,7 @@ __metadata:
react-table: ^7.8.0
redux: ^4.2.0
ts-node: ^10.8.1
tsx: ^3.8.0
typescript: ^4.7.3
yup: ^0.32.11
languageName: unknown