Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to platformatic 2 #27

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ export interface PlatformaticPgHooksConfig {
logger?:
| boolean
| {
level?: string;
level: (
| ("fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent")
| {
[k: string]: unknown;
}
) &
string;
transport?:
| {
target?: string;
Expand Down Expand Up @@ -78,6 +84,9 @@ export interface PlatformaticPgHooksConfig {
};
[k: string]: unknown;
};
loggerInstance?: {
[k: string]: unknown;
};
serializerOpts?: {
schema?: {
[k: string]: unknown;
Expand All @@ -97,7 +106,9 @@ export interface PlatformaticPgHooksConfig {
requestIdLogLabel?: string;
jsonShorthand?: boolean;
trustProxy?: boolean | string | string[] | number;
http2?: boolean;
https?: {
allowHTTP1?: boolean;
key:
| string
| {
Expand Down Expand Up @@ -226,6 +237,10 @@ export interface PlatformaticPgHooksConfig {
[k: string]: boolean;
};
};
ignoreRoutes?: {
method: string;
path: string;
}[];
enabled?: boolean | string;
/**
* Base URL for generated Platformatic DB routes
Expand Down Expand Up @@ -261,6 +276,10 @@ export interface PlatformaticPgHooksConfig {
* The user metadata key to store user roles
*/
roleKey?: string;
/**
* The user metadata path to store user roles
*/
rolePath?: string;
/**
* The role name for anonymous users
*/
Expand Down Expand Up @@ -335,11 +354,17 @@ export interface PlatformaticPgHooksConfig {
port?: number | string;
hostname?: string;
endpoint?: string;
server?: "own" | "parent";
server?: "own" | "parent" | "hide";
defaultMetrics?: {
enabled: boolean;
};
auth?: {
username: string;
password: string;
};
labels?: {
[k: string]: string;
};
};
plugins?: {
[k: string]: unknown;
Expand All @@ -352,6 +377,9 @@ export interface PlatformaticPgHooksConfig {
path?: string;
schema?: string;
url?: string;
fullResponse?: boolean;
fullRequest?: boolean;
validateResponse?: boolean;
}[];
watch?:
| {
Expand Down
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const { platformaticDB } = require('@platformatic/db')
const { buildServer } = require('@platformatic/service')
const { platformaticDB, DbStackable } = require('@platformatic/db')
const { buildServer, buildStackable } = require('@platformatic/service')
const { schema } = require('./lib/schema')
const { Generator } = require('./lib/generator')
const { join } = require('path')
Expand Down Expand Up @@ -40,10 +40,15 @@ function _buildServer (opts) {
return buildServer(opts, stackable)
}

async function buildPgHooksStackable (opts) {
return buildStackable(opts, stackable, DbStackable)
}

// break Fastify encapsulation
stackable[Symbol.for('skip-override')] = true

module.exports = stackable
module.exports.schema = schema
module.exports.Generator = Generator
module.exports.buildServer = _buildServer
module.exports.buildStackable = buildPgHooksStackable
3 changes: 2 additions & 1 deletion lib/schema.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict'

const { schema } = require('@platformatic/db')
const { version } = require('../package.json')

const platformaticPgHooksSchema = {
...schema.schema,
$id: 'platformatic-pg-hooks',
$id: `https://schemas.platformatic.dev/@platformatic/pg-hooks/${version}.json`,
title: 'Platformatic pg-hooks Config',
properties: {
...schema.properties,
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@
"start-platformatic-pg-hooks": "./cli/start.js"
},
"scripts": {
"build:config": "node lib/schema.js | json2ts > config.d.ts",
"build:config": "node lib/schema.js > schema.json && json2ts > config.d.ts < schema.json",
"build": "npm run build:config",
"test": "standard && borp --concurrency 1"
},
"devDependencies": {
"@matteo.collina/tspl": "^0.1.1",
"borp": "^0.17.0",
"fastify": "^4.26.0",
"platformatic": "^1.23.0",
"fastify": "^5.0.0",
"platformatic": "^2.0.0",
"standard": "^17.1.0"
},
"dependencies": {
"@platformatic/config": "^1.21.1",
"@platformatic/db": "^1.21.1",
"@platformatic/config": "^2.1.0",
"@platformatic/db": "^2.1.0",
"cron-parser": "^4.9.0",
"json-schema-to-typescript": "^15.0.0",
"minimist": "^1.2.0"
},
"engines": {
"node": "^18.8.0 || >=20.6.0"
"node": ">= 20.16.0"
}
}
Loading
Loading