Skip to content

Commit

Permalink
fix: deps
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Jul 24, 2024
1 parent ecf1339 commit 8b2e372
Show file tree
Hide file tree
Showing 24 changed files with 464 additions and 229 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: yarn --frozen-lockfile

- name: build
run: yarn build-prod
run: yarn build

- name: release
env:
Expand Down
5 changes: 1 addition & 4 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/bin/sh
[ -n "$CI" ] && exit 0
. "$(dirname "$0")/_/husky.sh"

./node_modules/.bin/commitlint-def $1
# exit 1 # uncomment to debug
dev-lib commitlint $1
4 changes: 1 addition & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/sh
[ -n "$CI" ] && exit 0
. "$(dirname "$0")/_/husky.sh"

./node_modules/.bin/lint-staged-def
dev-lib lint-staged
4 changes: 4 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// prettier-ignore
module.exports = [
...require('@naturalcycles/dev-lib/cfg/eslint.config'),
]
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"version": "2.61.0",
"scripts": {
"prepare": "husky",
"build": "dev-lib build",
"test": "dev-lib test",
"lint": "dev-lib lint",
"bt": "dev-lib bt",
"lbt": "dev-lib lbt",
"dev": "APP_ENV=dev node -r ts-node/register --watch ./src/test/server/server.ts",
"docs-serve": "NODE_OPTIONS=--openssl-legacy-provider vuepress dev docs",
"docs-build": "NODE_OPTIONS=--openssl-legacy-provider vuepress build docs",
Expand Down Expand Up @@ -37,7 +42,7 @@
},
"devDependencies": {
"@naturalcycles/bench-lib": "^3.0.0",
"@naturalcycles/dev-lib": "^13.0.0",
"@naturalcycles/dev-lib": "^15.0.4",
"@sentry/node": "^7.0.0",
"@types/ejs": "^3.0.0",
"@types/node": "^20.1.0",
Expand Down Expand Up @@ -71,7 +76,7 @@
"url": "https://github.com/NaturalCycles/backend-lib"
},
"engines": {
"node": ">=18.12.0"
"node": ">=20.12.0"
},
"type": "commonjs",
"description": "Standard library for making Express.js / AppEngine based backend services",
Expand Down
2 changes: 1 addition & 1 deletion scripts/validation.bench.script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ yarn tsn validation.bench
import http from 'node:http'
import { runCannon } from '@naturalcycles/bench-lib'
import { jsonSchema } from '@naturalcycles/js-lib'
import { objectSchema, stringSchema, runScript } from '@naturalcycles/nodejs-lib'
import { objectSchema, runScript, stringSchema } from '@naturalcycles/nodejs-lib'
import express = require('express')
import { BackendApplication, validateBody, validateRequest } from '../src'

Expand Down
3 changes: 2 additions & 1 deletion src/admin/secureHeaderMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ function requireSecureHeaderOrAdmin(

// Header provided - don't check for Admin
if (providedHeader) {
if (!secureHeaderValue || timingSafeStringEqual(providedHeader, secureHeaderValue))
if (!secureHeaderValue || timingSafeStringEqual(providedHeader, secureHeaderValue)) {
return next()
}

return next(
new AppError('secureHeader or adminToken is required', {
Expand Down
5 changes: 2 additions & 3 deletions src/deploy/deployGae.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { buildProdCommand } from '@naturalcycles/dev-lib'
import { _anyToError, _objectAssign, pRetry } from '@naturalcycles/js-lib'
import { appendToGithubSummary, execVoidCommandSync } from '@naturalcycles/nodejs-lib'
import { getBackendCfg } from './backend.cfg.util'
Expand All @@ -11,9 +10,9 @@ export interface DeployGaeOptions extends DeployPrepareOptions, DeployHealthChec
export async function deployGae(opt: DeployGaeOptions = {}): Promise<void> {
const { logOnFailure, logOnSuccess } = opt

// 1. build-prod
// 1. build

buildProdCommand()
execVoidCommandSync('yarn', ['build'])

// 2. deploy-prepare

Expand Down
4 changes: 2 additions & 2 deletions src/deploy/deployHealthCheck.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { inspect, InspectOptions } from 'node:util'
import { pDelay, _filterFalsyValues, _ms, _since, getFetcher } from '@naturalcycles/js-lib'
import { execVoidCommandSync, dimGrey, red } from '@naturalcycles/nodejs-lib'
import { _filterFalsyValues, _ms, _since, getFetcher, pDelay } from '@naturalcycles/js-lib'
import { dimGrey, execVoidCommandSync, red } from '@naturalcycles/nodejs-lib'
import { coloredHttpCode } from '../server/request.log.util'

export interface DeployHealthCheckOptions {
Expand Down
8 changes: 4 additions & 4 deletions src/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { deployGae } from './deployGae'
import { deployHealthCheck, DeployHealthCheckOptions } from './deployHealthCheck'
import { deployPrepare } from './deployPrepare'

export type { BackendCfg, DeployInfo, DeployHealthCheckOptions }
export type { BackendCfg, DeployHealthCheckOptions, DeployInfo }

export {
getBackendCfg,
createDeployInfo,
createAppYaml,
createDeployInfo,
deployGae,
deployPrepare,
deployHealthCheck,
deployPrepare,
getBackendCfg,
}
2 changes: 1 addition & 1 deletion src/general.server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
pExpectedError,
} from '@naturalcycles/js-lib'
import { arraySchema, deflateString, objectSchema } from '@naturalcycles/nodejs-lib'
import { getDefaultRouter, validateRequest } from './index'
import { safeJsonMiddleware } from './server/safeJsonMiddleware'
import { expressTestService } from './testing'
import { getDefaultRouter, validateRequest } from './index'

const router = getDefaultRouter()
router.get('/circular', safeJsonMiddleware(), async req => {
Expand Down
28 changes: 14 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ export * from './env/env.model'
export * from './env/env.shared.service'
export * from './gae/appEngine.util'
export * from './sentry/sentry.shared.service'
export * from './server/appEngineLogMiddleware'
export * from './server/asyncLocalStorageMiddleware'
export * from './server/basicAuthMiddleware'
export * from './server/bodyParserTimeoutMiddleware'
export * from './server/catchWrapper'
export * from './server/createDefaultApp'
export * from './server/createDefaultApp.model'
export * from './server/deployInfo.util'
export * from './server/getDefaultRouter'
export * from './server/bodyParserTimeoutMiddleware'
export * from './server/genericErrorMiddleware'
export * from './server/serverStatsMiddleware'
export * from './server/getDefaultRouter'
export * from './server/methodOverrideMiddleware'
export * from './server/notFoundMiddleware'
export * from './server/okMiddleware'
export * from './server/basicAuthMiddleware'
export * from './server/request.log.util'
export * from './server/request.util'
export * from './server/requestTimeoutMiddleware'
export * from './server/validation/validateRequest'
export * from './server/simpleRequestLoggerMiddleware'
export * from './server/safeJsonMiddleware'
export * from './server/server.model'
export * from './server/serverStatsMiddleware'
export * from './server/serverStatusMiddleware'
export * from './server/validation/validateMiddleware'
export * from './server/validation/zodValidateMiddleware'
export * from './server/request.log.util'
export * from './server/simpleRequestLoggerMiddleware'
export * from './server/startServer'
export * from './server/startServer.model'
export * from './server/asyncLocalStorageMiddleware'
export * from './server/server.model'
export * from './server/appEngineLogMiddleware'
export * from './server/safeJsonMiddleware'
export * from './server/request.util'
export * from './server/validation/validateMiddleware'
export * from './server/validation/validateRequest'
export * from './server/validation/zodValidateMiddleware'

export { onFinished }
3 changes: 2 additions & 1 deletion src/sentry/sentry.shared.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ export class SentrySharedService {
if (
data?.reportRate && // E.g rate of 0.1 means 10% of errors are reported
Math.random() > data.reportRate
)
) {
return
}

// This is to avoid Sentry cutting err.message to 253 characters
// It will log additional "breadcrumb object" before the error
Expand Down
2 changes: 1 addition & 1 deletion src/server/appEngineLogMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { inspect } from 'node:util'
import { AnyObject, CommonLogger } from '@naturalcycles/js-lib'
import { dimGrey, _inspect } from '@naturalcycles/nodejs-lib'
import { _inspect, dimGrey } from '@naturalcycles/nodejs-lib'
import { BackendRequestHandler } from './server.model'

const { GOOGLE_CLOUD_PROJECT, GAE_INSTANCE } = process.env
Expand Down
2 changes: 1 addition & 1 deletion src/server/asyncLocalStorageMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AsyncLocalStorage } from 'node:async_hooks'
import { _lazyValue, CommonLogger } from '@naturalcycles/js-lib'
import { gaeLogger, devLogger, ciLogger } from './appEngineLogMiddleware'
import { ciLogger, devLogger, gaeLogger } from './appEngineLogMiddleware'
import { BackendRequest, BackendRequestHandler } from './server.model'

const { GAE_INSTANCE, CI } = process.env
Expand Down
2 changes: 1 addition & 1 deletion src/server/createDefaultApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { BackendApplication, isGAE, methodOverrideMiddleware } from '..'
import { appEngineLogMiddleware } from './appEngineLogMiddleware'
import { asyncLocalStorageMiddleware } from './asyncLocalStorageMiddleware'
import {
DefaultAppCfg,
BackendRequestHandlerCfg,
BackendRequestHandlerWithPath,
DefaultAppCfg,
} from './createDefaultApp.model'
import { genericErrorMiddleware } from './genericErrorMiddleware'
import { notFoundMiddleware } from './notFoundMiddleware'
Expand Down
2 changes: 1 addition & 1 deletion src/server/server.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { CommonLogFunction, Promisable } from '@naturalcycles/js-lib'
import type { IRouter, Request, NextFunction, Response, Application } from 'express'
import type { Application, IRouter, NextFunction, Request, Response } from 'express'

/**
* Use this interface instead of express.Request in cases when TypeScript gives an error, because it haven't "included" this very file.
Expand Down
2 changes: 1 addition & 1 deletion src/server/validation/validateMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JsonSchema, JsonSchemaBuilder, _get, AppError } from '@naturalcycles/js-lib'
import { _get, AppError, JsonSchema, JsonSchemaBuilder } from '@naturalcycles/js-lib'
import { AjvSchema, AjvValidationError } from '@naturalcycles/nodejs-lib'
import { BackendRequestHandler } from '../server.model'
import { ReqValidationOptions } from './validateRequest'
Expand Down
1 change: 0 additions & 1 deletion src/test/env/test1.env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ const test1Env = {
a: 'a1',
}

// eslint-disable-next-line import/no-default-export
export default test1Env
1 change: 0 additions & 1 deletion src/test/env/test2.env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ const test2Env = {
a: 'a2',
}

// eslint-disable-next-line import/no-default-export
export default test2Env
2 changes: 1 addition & 1 deletion src/test/globalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ declare global {
}
}

// eslint-disable-next-line import/no-anonymous-default-export, import/no-default-export, unicorn/no-anonymous-default-export
// eslint-disable-next-line import/no-anonymous-default-export, unicorn/no-anonymous-default-export
export default async (): Promise<void> => {
const resources = [debugResource]

Expand Down
2 changes: 1 addition & 1 deletion src/test/globalTeardown.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { _since } from '@naturalcycles/js-lib'

// eslint-disable-next-line import/no-anonymous-default-export, import/no-default-export, unicorn/no-anonymous-default-export
// eslint-disable-next-line import/no-anonymous-default-export, unicorn/no-anonymous-default-export
export default async (): Promise<void> => {
const started = Date.now()
// @ts-expect-error
Expand Down
6 changes: 3 additions & 3 deletions src/test/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ console.log('startServer... ')
import { _errorLikeToErrorObject, AppError, pDelay } from '@naturalcycles/js-lib'
import { loginHtml } from '../../admin/adminMiddleware'
import {
startServer,
basicAuthMiddleware,
getDefaultRouter,
serverStatusMiddleware,
okMiddleware,
SentrySharedService,
basicAuthMiddleware,
serverStatusMiddleware,
startServer,
} from '../../index'
import {
getRequest,
Expand Down
Loading

0 comments on commit 8b2e372

Please sign in to comment.