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

create-gemforce-web-api

v1.0.3

Published

Build REST or GraphQL Web APIs by executing a single command

Downloads

7

Readme

create-gemforce-web-api

Build REST/GraphQL APIs with single command

Typescript REST/GraphQL code generator with JWT authentication

npx create-gemforce-web-api <project-name>

then

cd <project-name>
yarn install or npm install
yarn build or npm run build
yarn start or npm start

Example

to see what this generator creates for you checkout this project

Used libraries

Graphql

REST

Commands

Starting app:

yarn start or npm start

Starting with nodemon

yarn startd or npm run startd

Debuging:

yarn debug or npm run debug

Typescript build:

yarn build or npm run build

Typescript build (watch mode):

yarn watch or npm run watch

Creating typeorm migration

yarn migration:create or npm run migration:create

Environment Variables

The environment variables file can be found and modified in the .env in root of porject.

# Port number
PORT=4000

# JWT
# JWT access token secret key
ACCESS_TOKEN_SECRET=ajlkqowieuqowueoi
# JWT refresh token secret key (use different secrets for refresh and access tokens)
REFRESH_TOKEN_SECRET=qopwieioque1
# access token expiry (default 15 minutes)
ACCESS_TOKEN_EXPIRY=15m
# refresh token expiry (default 7 days)
REFRESH_TOKEN_EXPIRY=7d
# refresh token cookie name
REFRESH_TOKEN_COOKIE_NAME=jid

# CORS 
# you can set cors for client your application
CORS_CLIENT_HOST=http://localhost:3000

Project Structure

src\
 |--entities\             # data layer (model)
 |--dataAccess\           # data access layer (repos and migrations)
 |--services\             # service layer (pure app logic)
 |--services.contracts\   # types and interfaces for service layer
 |--host\                 # application host layer
   |--auth\               # authentication system with jwt
   |--graphql\            # all files related to graphql (if selected in cli)
   |--restApi\            # all files related to rest (if selected in cli)
   |--app.ts              # express app 
 |--ormconfig.json        # database config file
 |--Dockerfile            # docker file
 |--.nev                  # environment variables file
 |--index.ts              # application entry point
 

Routes

POST /refresh_token - get new tokens
POST /revoke_refresh_token - revoke refresh token

REST
POST /register body:{username,password,confirmPassword} - registers new user and sends access_token
POST /login body:{username,password} - authenticates user and sends access_token
GET /login - current user information
DELETE /login - logout current user

GraphQL
POST /graphql - graphql api (see graphql docs for register, login, logout)