├── .eslintignore
├── .eslintrc.js
├── .github
└── workflows
│ ├── codeql-analysis.yml
│ ├── diagram.yml
│ ├── release.yml
│ └── test.yml
├── .gitignore
├── .husky
├── common.sh
└── pre-commit
├── .npmignore
├── .prettierignore
├── .vscode
├── extensions.json
└── settings.json
├── CHANGELOG.md
├── LICENSE
├── README.md
├── banner.png
├── diagram.svg
├── example
└── typescript
│ ├── index.ts
│ └── routes
│ ├── _ignore_me
│ └── game.ts
│ ├── index.ts
│ ├── multipleparameters
│ ├── [id]-[name].ts
│ └── multiple
│ │ └── [id]-[name]-[game].ts
│ ├── profile
│ ├── [...id]
│ │ └── settings.ts
│ └── [game].ts
│ ├── spark
│ └── [...id].ts
│ └── user
│ ├── [id]
│ └── index.ts
│ └── index.ts
├── jest.config.js
├── package.json
├── pnpm-lock.yaml
├── release.config.js
├── renovate.json
├── src
├── index.ts
├── modules
│ ├── fastifyFileRoutesPlugin.ts
│ ├── index.ts
│ └── types.ts
└── utils
│ ├── autoload.ts
│ ├── handleParameters.ts
│ ├── index.ts
│ ├── isAcceptableFile.ts
│ ├── loadModule.ts
│ ├── scanFolders.ts
│ └── transformPathToUrl.ts
├── test
├── handleParameters.spec.ts
├── ignored
│ ├── .ignored.ts
│ ├── _ignore_me
│ │ └── game.ts
│ ├── _ignored.ts
│ ├── index.spec.ts
│ └── index.test.ts
├── isAcceptableFile.spec.ts
├── loadModule.spec.ts
├── routes.test.ts
└── transformPathToUrl.spec.ts
├── tsconfig.json
├── tsup.config.ts
└── vite.config.ts
/.eslintignore:
--------------------------------------------------------------------------------
1 | .pnp.cjs
2 | .yarn
3 | coverage
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | require("@rushstack/eslint-patch/modern-module-resolution");
2 |
3 | module.exports = {
4 | extends: [
5 | "@spa5k/eslint-config/profile/node",
6 | "@spa5k/eslint-config/mixins/friendly-locals",
7 | "@spa5k/eslint-config/mixins/tsdoc",
8 | ],
9 | parserOptions: { tsconfigRootDir: __dirname },
10 | rules: {
11 | "no-console": "error",
12 | "@typescript-eslint/consistent-type-definitions": "off",
13 | },
14 | };
15 |
--------------------------------------------------------------------------------
/.github/workflows/codeql-analysis.yml:
--------------------------------------------------------------------------------
1 | # For most projects, this workflow file will not need changing; you simply need
2 | # to commit it to your repository.
3 | #
4 | # You may wish to alter this file to override the set of languages analyzed,
5 | # or to provide custom queries or build logic.
6 | #
7 | # ******** NOTE ********
8 | # We have attempted to detect the languages in your repository. Please check
9 | # the `language` matrix defined below to confirm you have the correct set of
10 | # supported CodeQL languages.
11 | #
12 | name: "CodeQL"
13 |
14 | on:
15 | push:
16 | branches: [main]
17 | pull_request:
18 | # The branches below must be a subset of the branches above
19 | branches: [main]
20 | schedule:
21 | - cron: "30 19 * * 3"
22 |
23 | jobs:
24 | analyze:
25 | name: Analyze
26 | runs-on: ubuntu-latest
27 | permissions:
28 | actions: read
29 | contents: read
30 | security-events: write
31 |
32 | strategy:
33 | fail-fast: false
34 | matrix:
35 | language: ["javascript"]
36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37 | # Learn more about CodeQL language support at https://git.io/codeql-language-support
38 |
39 | steps:
40 | - name: Checkout repository
41 | uses: actions/checkout@v2
42 |
43 | # Initializes the CodeQL tools for scanning.
44 | - name: Initialize CodeQL
45 | uses: github/codeql-action/init@v1
46 | with:
47 | languages: ${{ matrix.language }}
48 | # If you wish to specify custom queries, you can do so here or in a config file.
49 | # By default, queries listed here will override any specified in a config file.
50 | # Prefix the list here with "+" to use these queries and those in the config file.
51 | # queries: ./path/to/local/query, your-org/your-repo/queries@main
52 |
53 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54 | # If this step fails, then you should remove it and run the build manually (see below)
55 | - name: Autobuild
56 | uses: github/codeql-action/autobuild@v1
57 |
58 | # ℹ️ Command-line programs to run using the OS shell.
59 | # 📚 https://git.io/JvXDl
60 |
61 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62 | # and modify them (or add more) to build your code if your project
63 | # uses a compiled language
64 |
65 | #- run: |
66 | # make bootstrap
67 | # make release
68 |
69 | - name: Perform CodeQL Analysis
70 | uses: github/codeql-action/analyze@v1
71 |
--------------------------------------------------------------------------------
/.github/workflows/diagram.yml:
--------------------------------------------------------------------------------
1 | name: Create diagram
2 | on:
3 | workflow_dispatch: {}
4 | push:
5 | branches:
6 | - next
7 | jobs:
8 | get_data:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - name: Checkout code
12 | uses: actions/checkout@master
13 | - name: Update diagram
14 | uses: githubocto/repo-visualizer@main
15 | with:
16 | excluded_paths: "ignore,.github,pnpm-lock.yaml,README.md,.vscode,.gitignore,.npmignore,assets,.yarn,.husky,yarn.lock"
17 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | # Run the workflow when a Pull Request is opened or when changes are pushed to master
4 | on:
5 | push:
6 | branches:
7 | - main
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-20.04
12 | strategy:
13 | matrix:
14 | node-version: [14]
15 | steps:
16 | - uses: actions/checkout@v2
17 | - uses: pnpm/action-setup@v2.0.1
18 | with:
19 | version: 6.31.0
20 | - name: Use Node.js ${{ matrix.node-version }}
21 | uses: actions/setup-node@v2
22 | with:
23 | node-version: ${{ matrix.node-version }}
24 | cache: "pnpm"
25 | - name: Install dependencies
26 | run: pnpm install
27 | - name: Build
28 | run: pnpm build
29 | - name: Release
30 | env:
31 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
33 | run: pnpm semantic-release
34 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Test
2 | on:
3 | pull_request:
4 | branches:
5 | - next
6 | push:
7 | branches:
8 | - next
9 | jobs:
10 | build:
11 | runs-on: ubuntu-20.04
12 | strategy:
13 | matrix:
14 | node-version: [14, 16, 17]
15 | steps:
16 | - uses: actions/checkout@v2
17 | - uses: pnpm/action-setup@v2.0.1
18 | with:
19 | version: 6.24.2
20 | - name: Use Node.js ${{ matrix.node-version }}
21 | uses: actions/setup-node@v2
22 | with:
23 | node-version: ${{ matrix.node-version }}
24 | cache: "pnpm"
25 | - name: Install dependencies
26 | run: pnpm install
27 | - name: Test
28 | run: pnpm ci:test
29 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.yarn/*
2 | !/.yarn/patches
3 | !/.yarn/plugins
4 | !/.yarn/releases
5 | !/.yarn/sdks
6 |
7 | # Swap the comments on the following lines if you don't wish to use zero-installs
8 | # Documentation here: https://yarnpkg.com/features/zero-installs
9 | !/.yarn/cache
10 | #/.pnp.*
11 | # Logs
12 | logs
13 | *.log
14 | npm-debug.log*
15 | yarn-debug.log*
16 | yarn-error.log*
17 | lerna-debug.log*
18 | .pnpm-debug.log*
19 |
20 | # Diagnostic reports (https://nodejs.org/api/report.html)
21 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
22 |
23 | # Runtime data
24 | pids
25 | *.pid
26 | *.seed
27 | *.pid.lock
28 |
29 | # Directory for instrumented libs generated by jscoverage/JSCover
30 | lib-cov
31 |
32 | # Coverage directory used by tools like istanbul
33 | coverage
34 | *.lcov
35 |
36 | # nyc test coverage
37 | .nyc_output
38 |
39 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
40 | .grunt
41 |
42 | # Bower dependency directory (https://bower.io/)
43 | bower_components
44 |
45 | # node-waf configuration
46 | .lock-wscript
47 |
48 | # Compiled binary addons (https://nodejs.org/api/addons.html)
49 | build/Release
50 |
51 | # Dependency directories
52 | node_modules/
53 | jspm_packages/
54 |
55 | # Snowpack dependency directory (https://snowpack.dev/)
56 | web_modules/
57 |
58 | # TypeScript cache
59 | *.tsbuildinfo
60 |
61 | # Optional npm cache directory
62 | .npm
63 |
64 | # Optional eslint cache
65 | .eslintcache
66 |
67 | # Microbundle cache
68 | .rpt2_cache/
69 | .rts2_cache_cjs/
70 | .rts2_cache_es/
71 | .rts2_cache_umd/
72 |
73 | # Optional REPL history
74 | .node_repl_history
75 |
76 | # Output of 'npm pack'
77 | *.tgz
78 |
79 | # Yarn Integrity file
80 | .yarn-integrity
81 |
82 | # dotenv environment variables file
83 | .env
84 | .env.test
85 | .env.production
86 |
87 | # parcel-bundler cache (https://parceljs.org/)
88 | .cache
89 | .parcel-cache
90 |
91 | # Next.js build output
92 | .next
93 | out
94 |
95 | # Nuxt.js build / generate output
96 | .nuxt
97 | dist
98 |
99 | # Gatsby files
100 | .cache/
101 | # Comment in the public line in if your project uses Gatsby and not Next.js
102 | # https://nextjs.org/blog/next-9-1#public-directory-support
103 | # public
104 |
105 | # vuepress build output
106 | .vuepress/dist
107 |
108 | # Serverless directories
109 | .serverless/
110 |
111 | # FuseBox cache
112 | .fusebox/
113 |
114 | # DynamoDB Local files
115 | .dynamodb/
116 |
117 | # TernJS port file
118 | .tern-port
119 |
120 | # Stores VSCode versions used for testing VSCode extensions
121 | .vscode-test
122 |
123 | # yarn v2
124 | # .yarn/cache
125 | # .yarn/unplugged
126 | .yarn/build-state.yml
127 | .yarn/install-state.gz
128 | # .pnp.*
129 |
130 | coverage
131 | .dc-cache
--------------------------------------------------------------------------------
/.husky/common.sh:
--------------------------------------------------------------------------------
1 | command_exists () {
2 | command -v "$1" >/dev/null 2>&1
3 | }
4 |
5 | # Workaround for Windows 10, Git Bash and Yarn
6 | if command_exists winpty && test -t 1; then
7 | exec < /dev/tty
8 | fi
9 |
10 |
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 | . "$(dirname "$0")/common.sh"
4 | # evaluate fnm
5 | eval $(fnm env | sed 1d)
6 | export PATH=$(cygpath $FNM_MULTISHELL_PATH):$PATH
7 |
8 | pnpm format
9 | pnpm lint
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | src
2 | assets
3 | .vscode
4 | .github
5 | .eslintrc
6 | test
7 | renovate.json
8 | .prettierignore
9 | .yarn
10 |
11 | CHANGELOG.md
12 | example
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | dist
2 | pnpm-lock.yaml
3 | .yarn
4 | .pnp.cjs
5 | coverage
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "arcanis.vscode-zipfs",
4 | "dbaeumer.vscode-eslint",
5 | "esbenp.prettier-vscode"
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "conventionalCommits.scopes": [
3 | "main",
4 | "deps",
5 | "actions",
6 | "test",
7 | "husky",
8 | "docs",
9 | "autoload",
10 | "parameters",
11 | "typescript"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [1.1.2](https://github.com/spa5k/fastify-file-routes/compare/v1.1.1...v1.1.2) (2022-03-10)
2 |
3 |
4 | ### Bug Fixes
5 |
6 | * **parameters:** 🐛 use replace for comptability ([94df65b](https://github.com/spa5k/fastify-file-routes/commit/94df65b47fd4e12eedced71940f22fc5de3838d9))
7 |
8 | ## [1.1.1](https://github.com/spa5k/fastify-file-routes/compare/v1.1.0...v1.1.1) (2021-12-21)
9 |
10 |
11 | ### Bug Fixes
12 |
13 | * **typescript:** 🔥 removing type json schema until a better way to infer type is thought off ([c274cc0](https://github.com/spa5k/fastify-file-routes/commit/c274cc0f444af0f3b7912013a4d9446429f363a6))
14 |
15 | # [1.1.0](https://github.com/spa5k/fastify-file-routes/compare/v1.0.3...v1.1.0) (2021-12-21)
16 |
17 | ### Bug Fixes
18 |
19 | - **actions:** 💚 removing tests from release CI ([6b7d850](https://github.com/spa5k/fastify-file-routes/commit/6b7d850cbd648fe21c84c494743c92121abbf593))
20 | - **parameters:** 🐛 fixing handleparameters ([b9d7b1d](https://github.com/spa5k/fastify-file-routes/commit/b9d7b1d245684edb7238d8355a4603bf919c4142))
21 |
22 | ### Features
23 |
24 | - **parameters:** ✨ added multiple parameters support for files and folders ([8854728](https://github.com/spa5k/fastify-file-routes/commit/885472815ef480166e95efb978e7f9e1601e4ffe))
25 |
26 | ## [1.0.3](https://github.com/spa5k/fastify-file-routes/compare/v1.0.2...v1.0.3) (2021-12-21)
27 |
28 | ### Bug Fixes
29 |
30 | - **autoload:** 🐛 adding a try catch to make sure that wrong route does not result in a crash ([0e42d3f](https://github.com/spa5k/fastify-file-routes/commit/0e42d3f3f61a5d9d5e44be2a7b1a88a578ee1973))
31 | - **test:** 🐛 removing empty route to let test run successfully ([2db5f71](https://github.com/spa5k/fastify-file-routes/commit/2db5f71a420f77fa405cfd6f5540357b92c68a4b))
32 |
33 | ## [1.0.2](https://github.com/spa5k/fastify-file-routes/compare/v1.0.1...v1.0.2) (2021-12-21)
34 |
35 | ### Bug Fixes
36 |
37 | - **deps:** 🐛 moving fastify-plugin to dependency to fix missing dep error ([b9b956f](https://github.com/spa5k/fastify-file-routes/commit/b9b956f2476b9132fc8f2678ea01f74279a74a4b))
38 |
39 | ## [1.0.1](https://github.com/spa5k/fastify-file-routes/compare/v1.0.0...v1.0.1) (2021-12-21)
40 |
41 | ### Bug Fixes
42 |
43 | - **actions:** 💚 fixing build related ci on release action ([f118ac2](https://github.com/spa5k/fastify-file-routes/commit/f118ac26170a534f7ff099dac89572fab48c70ec))
44 |
45 | # 1.0.0 (2021-12-21)
46 |
47 | ### Features
48 |
49 | - **main:** ✨ added initial implmentation ([#2](https://github.com/spa5k/fastify-file-routes/issues/2)) ([3222faf](https://github.com/spa5k/fastify-file-routes/commit/3222fafce2dd5217bfc67b90e60f0a80ce729780))
50 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 spa5k
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Fastify File Routes
2 |
3 |
4 |
5 | 
6 |
7 | [](https://www.npmjs.com/package/fastify-file-routes)
8 | [](https://www.npmjs.com/package/fastify-file-routes)
9 | 
10 |
11 | A Fastify plugin that provides a file system routes, based on the way Next.JS file system routing works, including all possible features.
12 |
13 |