Skip to content

Commit

Permalink
chore: bump all dev dependencies (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
simenandre authored Aug 13, 2023
1 parent a48c8f7 commit c143e9c
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 108 deletions.
18 changes: 18 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
extends: ['@bjerk/eslint-config', 'plugin:jest/recommended'],
plugins: ['jest'],
ignorePatterns: ['dist', 'node_modules'],
overrides: [
{
files: 'jest.config.*',
rules: {
'import/no-default-export': 'off',
},
},
],
parserOptions: {
project: './tsconfig.eslint.json',

tsconfigRootDir: __dirname,
},
};
3 changes: 0 additions & 3 deletions .eslintrc.js

This file was deleted.

6 changes: 3 additions & 3 deletions examples/fastify-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const inputData = z.object({
bookingId: z.string(),
});

const server = () => {
const server = async () => {
const fastify = Fastify().withTypeProvider<TypeBoxTypeProvider>();

fastify.register(
await fastify.register(
pubSubFastifyPlugin,
makePubSubConfig({
parser: d => inputData.parse(d),
Expand All @@ -30,4 +30,4 @@ const server = () => {
fastify.server.listen(8000);
};

server();
void server();
24 changes: 9 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@
],
"scripts": {
"build": "tsc",
"lint": "eslint '**/*.ts' --fix",
"generate:docs": "typedoc --readme none --out docs src",
"lint": "eslint '**/*.ts' --fix",
"prepare": "husky install",
"test": "jest --coverage src",
"prepare": "husky install"
"format": "prettier --write '**/*.ts'",
"format:check": "prettier --check '**/*.ts'"
},
"lint-staged": {
"*.ts": [
"prettier --write"
]
},
"prettier": "@cobraz/prettier",
"prettier": "@simenandre/prettier",
"dependencies": {
"@fastify/type-provider-typebox": "^3.4.0",
"@sinclair/typebox": "^0.30.0",
Expand All @@ -44,27 +46,19 @@
"pino-cloud-logging": "^1.0.3"
},
"devDependencies": {
"@bjerk/eslint-config": "^4.0.0",
"@cobraz/prettier": "^2.0.0",
"@bjerk/eslint-config": "^5.4.0",
"@simenandre/prettier": "^5.0.0",
"@tsconfig/node16": "^1.0.3",
"@types/jest": "^29.5.0",
"@types/json-schema-faker": "^0.5.1",
"@types/node": "^16",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"eslint": "^8.38.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-unicorn": "^47.0.0",
"eslint-plugin-jest": "^27.2.3",
"husky": "^8.0.0",
"jest": "^29.5.0",
"json-schema-faker": "^0.5.0-rcv.32",
"lint-staged": "^13.1.0",
"prettier": "^2.6.2",
"prettier": "^3.0.0",
"ts-jest": "^29.1.0",
"typedoc": "^0.24.4",
"typedoc-plugin-markdown": "^3.1.1",
Expand Down
14 changes: 11 additions & 3 deletions src/cloud-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@ import type * as express from 'express';
import pino from 'pino';
import { gcpLogOptions } from 'pino-cloud-logging';
import { handlePubSubMessage } from './common';
import { PubSubConfig, PubSubHandler } from './types';
import { PubSubConfig, PubSubHandler, PubSubMessage } from './types';

export type CloudRunRequest = express.Request<
unknown,
unknown,
{
message: PubSubMessage;
}
>;

export interface PubSubCloudFunctionsConfig<Data, Context>
extends PubSubConfig<Data, Context> {
logger?: pino.LoggerOptions;

context?: (req?: express.Request) => Context | Promise<Context>;
context?: (req?: CloudRunRequest) => Context | Promise<Context>;
}

export type CloudFunctionFun = (
req: express.Request,
req: CloudRunRequest,
res: express.Response,
) => Promise<void>;

Expand Down
2 changes: 1 addition & 1 deletion src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function handlePubSubMessage<Data, Context, Logger>(
const { message, parseJson = true, parser, handler, context, log } = args;
const bufferString = Buffer.from(message.data, 'base64').toString().trim();

let data = parseJson ? JSON.parse(bufferString) : bufferString;
let data = (parseJson ? JSON.parse(bufferString) : bufferString) as Data;

if (parser) {
data = await parser(data);
Expand Down
2 changes: 1 addition & 1 deletion src/fastify-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const pubSubFastifyPluginFn = async <Data, Context>(
},
);

return reply.code(res?.statusCode || 204).send();
return reply.code(res?.statusCode ?? 204).send();
} catch (error) {
if (onError) {
await onError(error, context);
Expand Down
10 changes: 10 additions & 0 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "@tsconfig/node16/tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"declaration": true,
"sourceMap": true
},
"include": ["src/**/*", "examples/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
Loading

0 comments on commit c143e9c

Please sign in to comment.