
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@phila/philaroute
Advanced tools
Basic HTTP router for AWS API Gateway / Proxy Lambdas with composable pipelines built with TypeScript.
A lightweight, composable HTTP router for Node.js Lambda/API Gateway environments, written in TypeScript. Supports composable middleware pipelines and CORS out of the box.
npm install philaroute
Philaroute revolves around the usage of pipelines to composably and easily manage different routes and controllers. Parsing and response are built in. Effectively, you need to supply an array of functions that utilize the following type:
export type RestAccumulator = {
request?: {
params?: {
[key: string]: string
},
body?: any,
headers?: {
[key: string]: string
},
mvHeaders?: {
[key: string]: string[]
},
}
data?: {
[key: string]: any
},
response: {
statusCode?: number,
headers?: {
[key: string]: string
},
isBase64Encoded?: boolean,
body?: string | Record<string, any> | any[]
}
};
type RestPipelineFn = (acc: RestAccumulator): Promise<RestAccumulator>
import { Router, http } from 'philaroute';
const { HttpStatus } = http;
const router = Router({ cors: { 'Access-Control-Allow-Origin': '*' } });
const world = router.path('/hello');
world.get([
http.set({
body: 'Hello World!'
})
]);
// In your Lambda handler:
export const main = async (event) => {
return router.routeToPath(event);
};
Advanced pipeline example
import { validate } from './validate';
import { opensearch } from './opensearch';
const router = Router();
const page = router.path('page')
page.get([
validate.pageName,
validate.userToken,
opensearch.search(['search, vector']), // does relevant logic to search two different collections in paralle, puts data into acc.data.
opensearch.rank, // ranks search results, applies to acc.response.body
// Can use http.set to customize response; otherwise acc.response.body will be preferentially returned, acc.data otherwise.
]);
---
## CORS
CORS headers can be set globally when creating the router or updated later:
```typescript
const worldRouter = router({
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET,POST,OPTIONS',
});
npm run build
npm test
npm run lint
npm run format
MIT © City of Philadelphia
For more information, see the Official Project Documentation.
FAQs
Basic HTTP router for AWS API Gateway / Proxy Lambdas with composable pipelines built with TypeScript.
We found that @phila/philaroute demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.