Skip to content

Commit

Permalink
chore: prepare for release (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
Danilqa authored Jan 25, 2025
1 parent 69707e8 commit d7e9cf9
Show file tree
Hide file tree
Showing 4 changed files with 5,660 additions and 3,518 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ export default [
];
```

Classes
```js
export default class Resource {
get(req, res, routeParams) {}

post(req, res, routeParams) {}

patch(req, res, routeParams) {}
}
```

# Documentation

```bash
Expand All @@ -95,6 +106,7 @@ Usage:
Methods routing:
* [Any method](https://node-file-router.js.org/docs/usage-guide#any-method)
* [Object with methods](https://node-file-router.js.org/docs/usage-guide#object-with-methods)
* [Class with methods](https://node-file-router.js.org/docs/usage-guide#class-with-methods)
* [Methods in filenames](https://node-file-router.js.org/docs/usage-guide#methods-in-filenames)

Route matching:
Expand All @@ -121,4 +133,4 @@ new features and fixes. Feel free to ask questions, voice ideas, and share your

# Developing

To begin development and contribution, read [this guide](/contributing/developing.md).
To begin development and contribution, read [this guide](/contributing/developing.md).
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-file-router",
"version": "0.6.0",
"version": "0.7.0",
"description": "A powerful file-based routing for Express.js, Bun, pure Node.js and more",
"scripts": {
"dev:sandbox": "tsnd examples/sandbox/server.ts",
Expand Down
22 changes: 22 additions & 0 deletions website/docs/usage-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,28 @@ export default {
}
```

### Class with Methods

Specify functions for each method within the class. The main requirement is that it should be the default export.

```js
export default class Resource {
get(req, res, routeParams) {
const { documentId, draftId } = routeParams;
res.end(`Requested document ${documentId} and his draft ${draftId}`);
}

post(req, res, routeParams) {
const { documentId, draftId } = routeParams;
res.end(`Created draft ${draftId} for document ${documentId}`);
}

patch(req, res, routeParams) {
// ...
}
}
```

### Methods in Filenames

Use the `.[method].` suffix to directly specify methods in the filenames. This approach can be used for
Expand Down
Loading

0 comments on commit d7e9cf9

Please sign in to comment.