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

Glob ignore underscore folder fix #16

Merged
merged 1 commit into from
Nov 9, 2022
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
6 changes: 3 additions & 3 deletions example/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions example/functions/_utils/abc/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default async (req, res) => {
res.status(200).send(`test, ${req.query.name}!`)
}
17 changes: 5 additions & 12 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
})
)

Expand All @@ -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 _
]
})
Expand All @@ -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
}

Expand Down