npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

generator-serverless-concourse

v0.1.3

Published

Yeoman Generator for serverless-concourse that creates new endpoints with tests and route registration.

Downloads

6

Readme

generator-serverless-concourse

Yeoman Generator for serverless-concourse that creates new endpoints with tests and route registration.

This generator is a work in progress and should not be used in either production or development.

Usage

Make sure you're in your project root that is based on serverless-concourse. To create your first endpoints, use the following command:

yo serverless-concourse [verb] [endpoint]

The command takes a verb and an endpoint name as parameters. Ie.: yo serverless-concourse get users. The plural form of users tells the generator that we are looking for a list of users as opposed to a specific user which would be referred to as yo serverless-concourse get user.

Verbs

Accepted verbs are the following:

  • GET with a plural endpoint name: a searchable and paginated list of items
    • GET /items/
  • GET with a singular endpoint name: retrieves a single item identified by an Id parameter
    • GET /items/:itemId
  • POST will always assume plural (no Id): creates a new item
    • POST /items/
  • PUT will always assume singular (with Id): modifies an existing item
    • PUT /items/:itemId
  • DELETE will always assume singular (with Id): removes an existing item
    • DELETE /items/:itemId

Endpoints

It is possible to create nested endpoints by making the endpoint name a path. Here, plurality will matter for each name in the path, ie: yo serverless-concourse get user/addresses will refer to getting a list of addresses for a specific user as opposed to the list being nested under the users endpoint. In other words, each generated address endpoint will be effective under a specific user - a one to many relation. If we just wanted to nest endpoints we could use plural forms in the path, ie: yo serverless-concourse get users/vips.

Examples

Let's see some specific examples of commands and their generated code:

Plural endpoint

$ yo serverless-concourse get addresses
? API version? v1
? Function name addresses
? HTTP verb GET
? HTTP path addresses
? Handler name getAddresses
? Enable CORS? No
   create functions/v1/addresses/getAddresses.ts
   create __tests__/v1/addresses/getAddresses.ts

YAML generated:

v1_addresses_getAddresses:
    handler: functions/v1/addresses/getAddresses.getAddresses
    events: [{http: {method: GET, path: 'users/{userId}/users/{userId}/addresses', request: {parameters: {paths: {userId: true}}}}}]

Singular endpoint with id

$ yo serverless-concourse get address
? API version? v1
? Function name addresses
? HTTP verb GET
? HTTP path addresses/{addressId}
? Handler name getAddress
? Enable CORS? No
   create functions/v1/addresses/getAddress.ts
   create __tests__/v1/addresses/getAddress.ts

YAML generated:

v1_addresses_getAddress:
    handler: functions/v1/addresses/getAddress.getAddress
    events: [{http: {method: GET, path: 'addresses/{addressId}', request: {parameters: {paths: {addressId: true}}}}}]

Endpoints with predefined plurality

Ie. POST always plural, PUT and DELETE always singular with id

$ yo serverless-concourse post address
? API version? v1
? Function name addresses
? HTTP verb POST
? HTTP path addresses
? Handler name postAddress
? Enable CORS? No
   create functions/v1/addresses/postAddress.ts
   create __tests__/v1/addresses/postAddress.ts
$ yo serverless-concourse put address
? API version? v1
? Function name addresses
? HTTP verb PUT
? HTTP path addresses/{addressId}
? Handler name putAddress
? Enable CORS? No
   create functions/v1/addresses/putAddress.ts
   create __tests__/v1/addresses/putAddress.ts
$ yo serverless-concourse delete address
? API version? v1
? Function name addresses
? HTTP verb DELETE
? HTTP path addresses/{addressId}
? Handler name deleteAddress
? Enable CORS? No
   create functions/v1/addresses/deleteAddress.ts
   create __tests__/v1/addresses/deleteAddress.ts

YAML generated:

v1_addresses_postAddress:
    handler: functions/v1/addresses/postAddress.postAddress
    events: [{http: {method: POST, path: addresses}}]
v1_addresses_putAddress:
    handler: functions/v1/addresses/putAddress.putAddress
    events: [{http: {method: PUT, path: 'addresses/{addressId}', request: {parameters: {paths: {addressId: true}}}}}]
v1_addresses_deleteAddress:
    handler: functions/v1/addresses/deleteAddress.deleteAddress
    events: [{http: {method: DELETE, path: 'addresses/{addressId}', request: {parameters: {paths: {addressId: true}}}}}]

Generate CRUD endpoints

$ yo serverless-concourse crud messages
? API version? v1
? Function name messages
? Enable CORS? No
? Generate CRUD? Yes
   create functions/v1/messages/getMessages.ts
   create __tests__/v1/messages/getMessages.ts
   create functions/v1/messages/getMessage.ts
   create __tests__/v1/messages/getMessage.ts
   create functions/v1/messages/postMessage.ts
   create __tests__/v1/messages/postMessage.ts
   create functions/v1/messages/putMessage.ts
   create __tests__/v1/messages/putMessage.ts
   create functions/v1/messages/deleteMessage.ts
   create __tests__/v1/messages/deleteMessage.ts

YAML generated:

    v1_messages_getMessages:
        handler: functions/v1/messages/getMessages.getMessages
        events: [{http: {method: GET, path: messages}}]
    v1_messages_getMessage:
        handler: functions/v1/messages/getMessage.getMessage
        events: [{http: {method: GET, path: 'messages/{messageId}', request: {parameters: {paths: {messageId: true}}}}}]
    v1_messages_postMessage:
        handler: functions/v1/messages/postMessage.postMessage
        events: [{http: {method: POST, path: messages}}]
    v1_messages_putMessage:
        handler: functions/v1/messages/putMessage.putMessage
        events: [{http: {method: PUT, path: 'messages/{messageId}', request: {parameters: {paths: {messageId: true}}}}}]
    v1_messages_deleteMessage:
        handler: functions/v1/messages/deleteMessage.deleteMessage
        events: [{http: {method: DELETE, path: 'messages/{messageId}', request: {parameters: {paths: {messageId: true}}}}}]

Nested endpoints

In this case let's assume we want to manage attachments to a specific message (hence the singular reference in the command to message).

$ yo serverless-concourse crud message/attachments
? API version? v1
? Function name attachments
? Enable CORS? No
? Generate CRUD? Yes
   create functions/v1/messages/attachments/getAttachments.ts
   create __tests__/v1/messages/attachments/getAttachments.ts
   create functions/v1/messages/attachments/getAttachment.ts
   create __tests__/v1/messages/attachments/getAttachment.ts
   create functions/v1/messages/attachments/postAttachment.ts
   create __tests__/v1/messages/attachments/postAttachment.ts
   create functions/v1/messages/attachments/putAttachment.ts
   create __tests__/v1/messages/attachments/putAttachment.ts
   create functions/v1/messages/attachments/deleteAttachment.ts
   create __tests__/v1/messages/attachments/deleteAttachment.ts

YAML generated:

v1_attachments_getAttachments:
    handler: functions/v1/messages/attachments/getAttachments.getAttachments
    events: [{http: {method: GET, path: 'messages/{messageId}/attachments', request: {parameters: {paths: {messageId: true}}}}}]
v1_attachments_getAttachment:
    handler: functions/v1/messages/attachments/getAttachment.getAttachment
    events: [{http: {method: GET, path: 'messages/{messageId}/attachments/{attachmentId}', request: {parameters: {paths: {messageId: true, attachmentId: true}}}}}]
v1_attachments_postAttachment:
    handler: functions/v1/messages/attachments/postAttachment.postAttachment
    events: [{http: {method: POST, path: 'messages/{messageId}/attachments', request: {parameters: {paths: {messageId: true}}}}}]
v1_attachments_putAttachment:
    handler: functions/v1/messages/attachments/putAttachment.putAttachment
    events: [{http: {method: PUT, path: 'messages/{messageId}/attachments/{attachmentId}', request: {parameters: {paths: {messageId: true, attachmentId: true}}}}}]
v1_attachments_deleteAttachment:
    handler: functions/v1/messages/attachments/deleteAttachment.deleteAttachment
    events: [{http: {method: DELETE, path: 'messages/{messageId}/attachments/{attachmentId}', request: {parameters: {paths: {messageId: true, attachmentId: true}}}}}]