@renanlido/serverless-routes-generator
TypeScript icon, indicating that this package has built-in type declarations

1.0.15 • Public • Published

@renanlido/serverless-routes-generator

GitHub Repo stars npm GitHub npm GitHub top language

Full starter stack to develop CJS/ESM compatible npm packages with TypeScript, Vitest, ESLint, Prettier, and GitHub Actions.

Introducing serverless-routes-generator – an npm package designed to simplify route creation for Serverless applications. With just a few commands, you can effortlessly generate and manage routes in your serverless.ts file, eliminating the need for manual configuration. Whether you’re building a small project or scaling a complex architecture, serverless-routes-generator streamlines your workflow, allowing you to focus on developing features instead of handling boilerplate setup. Enhance your Serverless development experience today with this intuitive and efficient tool!

Tools

  • TypeScript: TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
  • biome: Biome statically analyzes your code to quickly find problems.
  • GitHub Actions: Automate your workflow from idea to production.
  • tsup - Zero-config bundler for tiny TypeScript libraries.
  • glob - Match files using the patterns the shell uses, like stars and stuff.

Features

  • ESM/CJS ready - Write your code in TypeScript and publish it as ESM and CJS with 0 configuration.
  • Are The types wrong? ready - Passes all the checks for typings on https://arethetypeswrong.github.io/ by default.
  • ESM/CJS test apps setup - Test your package in both ESM and CJS environments already setup for you.
  • Test runner setup - Coming soon
  • Linting setup - Lint your code with ESLint and Prettier already setup for you.
  • GitHub Actions setup - Automate deployments to npm by using GitHub Actions.

Usage Setup

  1. Install the package:

npm

npm install @renanlido/serverless-routes-generator

yarn

yarn add @renanlido/serverless-routes-generator

pnpm

pnpm add @renanlido/serverless-routes-generator
  1. Create de configuration script run and customize the configuration for your project:
{
  "scripts": {
    "generator-init": "serverless-routes-generator init"
  }
}
  1. Integrate the functional decorator on your serverless handler:
import { createHandler } from "@renanlido/serverless-routes-generator";

export const generatePresignedLink = createHandler(
  {
    method: 'POST',
    path: 'test/route-path',
    cors: true,
    name: 'route-path',
  },
  () => {
  // Any handler function here

    return {
      statusCode: 200,
      body: JSON.stringify({ message: 'Hello World' }),
    }
  },
)
  1. Run the command to generate the routes:
{
  "scripts": {
    "generate-routes": "serverless-routes-generator generate"
  }
}

Development Setup

  1. Clone the repository:
git clone git@github.com:renanlido/serverless-routes-generator.git
  1. Install the dependencies:
pnpm install

Development Scripts

  • npm run generate:routes:bin - Generate the routes.
  • npm run generate:bin:init - Generate the bin.
  • npm run generate:bin - Generate the bin.
  • npm run generate:routes - Generate the routes.
  • npm run link:bin - Link the package to the global scope.
  • npm run build - Build the package.
  • npm run type-check - Check the types.
  • npm run check:fix - Check and fix the code.
  • npm run validate - Run the type-check and check:fix scripts.
  • npm run check:exports - Check the exports.
  • npm run local-release - Build the package, version it, and publish it locally.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE.md file for details.

Acknowledgements

This project was inspired by the need to streamline route management in Serverless applications. Special thanks to the open-source community for their valuable contributions.

Package Sidebar

Install

npm i @renanlido/serverless-routes-generator

Weekly Downloads

50

Version

1.0.15

License

MIT

Unpacked Size

141 kB

Total Files

43

Last publish

Collaborators

  • renanlido