Skip to content

Commit 6a0d9ea

Browse files
authored
[chore] do not include main route when bundling functions (#117)
* do not include main.rs route when using bundle macro * `4.0.6` * fix regex
1 parent 2376463 commit 6a0d9ea

File tree

8 files changed

+31
-10
lines changed

8 files changed

+31
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Community-maintained package to support using [Rust](https://www.rust-lang.org/)
2828
{
2929
"functions": {
3030
"api/**/*.rs": {
31-
"runtime": "[email protected].5"
31+
"runtime": "[email protected].6"
3232
}
3333
}
3434
}
@@ -174,7 +174,7 @@ pub async fn handler(req: Request) -> Result<Response<Body>, Error> {}
174174
{
175175
"functions": {
176176
"api/main.rs": {
177-
"runtime": "[email protected].5"
177+
"runtime": "[email protected].6"
178178
}
179179
}
180180
}

examples/cron/vercel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"outputDirectory": "public",
33
"functions": {
44
"api/**/*.rs": {
5-
"runtime": "[email protected].5"
5+
"runtime": "[email protected].6"
66
}
77
},
88
"crons": [

examples/nextjs/vercel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"functions": {
33
"api/**/*.rs": {
4-
"runtime": "[email protected].5"
4+
"runtime": "[email protected].6"
55
}
66
}
77
}

examples/route-merge/vercel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"functions": {
33
"api/main.rs": {
4-
"runtime": "[email protected].5"
4+
"runtime": "[email protected].6"
55
}
66
}
77
}

examples/simple/vercel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"outputDirectory": "public",
33
"functions": {
44
"api/**/*.rs": {
5-
"runtime": "[email protected].5"
5+
"runtime": "[email protected].6"
66
}
77
}
88
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vercel-rust",
3-
"version": "4.0.5",
3+
"version": "4.0.6",
44
"description": "Rust runtime for Vercel Functions.",
55
"homepage": "https://github.com/vercel-community/rust",
66
"repository": {

src/lib/routes.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
import { generateRoutes } from './routes';
22

33
describe('generateRoutes', () => {
4+
it('should filter out entry point route', () => {
5+
const staticRoutes = ['api/main.rs', 'api/foo.rs', 'api/bar/baz.rs'];
6+
7+
expect(generateRoutes(staticRoutes)).toMatchInlineSnapshot(`
8+
[
9+
{
10+
"dest": "/api/bar/baz",
11+
"path": "api/bar/baz",
12+
"src": "/api/bar/baz",
13+
},
14+
{
15+
"dest": "/api/foo",
16+
"path": "api/foo",
17+
"src": "/api/foo",
18+
},
19+
]
20+
`);
21+
});
22+
423
it('should generate static routes', () => {
524
const staticRoutes = ['api/foo.rs', 'api/bar/baz.rs'];
625

src/lib/routes.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,11 @@ export function parseRoute(filepath: string): ParsedRoute {
7979
}
8080

8181
export function generateRoutes(files: string[]): Route[] {
82-
const routes = files.map((file) => {
83-
return parseRoute(file);
84-
});
82+
const routes = files
83+
.map((file) => {
84+
return parseRoute(file);
85+
})
86+
.filter((r) => r.src !== '/api/main');
8587

8688
const orderedRoutes = orderBy(
8789
routes,

0 commit comments

Comments
 (0)