From ece0c6d9a8e07a1755a7632daa478347e0c9707e Mon Sep 17 00:00:00 2001 From: Johan Eliasson Date: Mon, 7 Nov 2022 20:02:58 +0100 Subject: [PATCH] update --- example/docker-compose.yaml | 6 +++--- example/functions/_utils/abc/test.js | 3 +++ server.ts | 17 +++++------------ 3 files changed, 11 insertions(+), 15 deletions(-) create mode 100644 example/functions/_utils/abc/test.js diff --git a/example/docker-compose.yaml b/example/docker-compose.yaml index b6138b9..988674a 100644 --- a/example/docker-compose.yaml +++ b/example/docker-compose.yaml @@ -24,7 +24,7 @@ services: ports: - '5432:5432' graphql-engine: - image: hasura/graphql-engine:v2.2.0 + image: hasura/graphql-engine:v2.15.0 container_name: 'hasura' depends_on: - 'postgres' @@ -43,7 +43,7 @@ services: - 'traefik.http.routers.hasura.rule=Host(`localhost`) && PathPrefix(`/`)' - 'traefik.http.routers.hasura.entrypoints=web' auth: - image: nhost/hasura-auth:latest + image: nhost/hasura-auth:0.15.0 container_name: 'auth' depends_on: - postgres @@ -72,7 +72,7 @@ services: - 'traefik.http.routers.auth.middlewares=strip-auth@docker' - 'traefik.http.routers.auth.entrypoints=web' storage: - image: nhost/hasura-storage:0.2.1 + image: nhost/hasura-storage:0.2.7 container_name: 'storage' depends_on: - postgres diff --git a/example/functions/_utils/abc/test.js b/example/functions/_utils/abc/test.js new file mode 100644 index 0000000..cb0fa65 --- /dev/null +++ b/example/functions/_utils/abc/test.js @@ -0,0 +1,3 @@ +export default async (req, res) => { + res.status(200).send(`test, ${req.query.name}!`) +} diff --git a/server.ts b/server.ts index b9a2257..579d1a1 100644 --- a/server.ts +++ b/server.ts @@ -13,7 +13,7 @@ const main = async () => { // skipping /healthz because docker health checks it every second or so app.use( morgan('tiny', { - skip: req => req.url === '/healthz' + skip: (req) => req.url === '/healthz' }) ) @@ -26,15 +26,12 @@ const main = async () => { res.status(200).send('ok') }) - const functionsPath = path.join( - process.cwd(), - process.env.FUNCTIONS_RELATIVE_PATH - ) + const functionsPath = path.join(process.cwd(), process.env.FUNCTIONS_RELATIVE_PATH) const files = glob.sync('**/*.@(js|ts)', { cwd: functionsPath, ignore: [ '**/node_modules/**', // ignore node_modules directories - '**/_**/*', // ignore files inside directories that start with _ + '**/_*/**', // ignore files inside directories that start with _ '**/_*' // ignore files that start with _ ] }) @@ -46,16 +43,12 @@ const main = async () => { const relativePath = path.relative(process.env.NHOST_PROJECT_PATH, file) if (handler) { - const route = `/${file}` - .replace(/(\.ts|\.js)$/, '') - .replace(/\/index$/, '/') + const route = `/${file}`.replace(/(\.ts|\.js)$/, '').replace(/\/index$/, '/') try { app.all(route, handler) } catch (error) { - console.warn( - `Unable to load file ${relativePath} as a Serverless Function` - ) + console.warn(`Unable to load file ${relativePath} as a Serverless Function`) continue }