All Projects → pharindoko → Json Serverless

pharindoko / Json Serverless

Licence: mit
Transform a JSON file into a serverless REST API in AWS cloud

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Json Serverless

Autoserver
Create a full-featured REST/GraphQL API from a configuration file
Stars: ✭ 188 (+74.07%)
Mutual labels:  api, graphql, rest-api, serverless, json, deployment
Up
Up focuses on deploying "vanilla" HTTP servers so there's nothing new to learn, just develop with your favorite existing frameworks such as Express, Koa, Django, Golang net/http or others.
Stars: ✭ 8,439 (+7713.89%)
Mutual labels:  api, graphql, aws, serverless, lambda, deployment
Webiny Js
Enterprise open-source serverless CMS. Includes a headless CMS, page builder, form builder and file manager. Easy to customize and expand. Deploys to AWS.
Stars: ✭ 4,869 (+4408.33%)
Mutual labels:  graphql, aws, serverless, lambda, serverless-framework
Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (-52.78%)
Mutual labels:  api, aws, serverless, lambda, serverless-framework
Dialetus Service
API to Informal dictionary for the idiomatic expressions that each Brazilian region It has
Stars: ✭ 202 (+87.04%)
Mutual labels:  api, rest-api, aws, serverless, json
Networking
⚡️ Elegantly connect to a REST JSON Api. URLSession + Combine + Decodable + Generics = <3
Stars: ✭ 499 (+362.04%)
Mutual labels:  api, rest-api, rest, json
Spyke
Interact with REST services in an ActiveRecord-like manner
Stars: ✭ 591 (+447.22%)
Mutual labels:  api, rest-api, rest, json
Aws Lambda Vpc Nat Examples
Example of setting up AWS lambda function with VPC and NAT
Stars: ✭ 92 (-14.81%)
Mutual labels:  aws, serverless, lambda, serverless-framework
Chalice
Python Serverless Microframework for AWS
Stars: ✭ 8,513 (+7782.41%)
Mutual labels:  aws, serverless, lambda, serverless-framework
Serverless Bundle
Optimized packages for ES6 and TypeScript Node.js Lambda functions without any configuration.
Stars: ✭ 295 (+173.15%)
Mutual labels:  webpack, aws, serverless, lambda
Fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Stars: ✭ 39,588 (+36555.56%)
Mutual labels:  api, rest, swagger-ui, json
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (-54.63%)
Mutual labels:  api, rest-api, rest, json
Json Api Dart
JSON:API client for Dart/Flutter
Stars: ✭ 53 (-50.93%)
Mutual labels:  api, rest-api, rest, json
Nodb
NoDB isn't a database.. but it sort of looks like one.
Stars: ✭ 353 (+226.85%)
Mutual labels:  aws, serverless, lambda, json
Aws Serverless Airline Booking
Airline Booking is a sample web application that provides Flight Search, Flight Payment, Flight Booking and Loyalty points including end-to-end testing, GraphQL and CI/CD. This web application was the theme of Build on Serverless Season 2 on AWS Twitch running from April 24th until end of August in 2019.
Stars: ✭ 1,290 (+1094.44%)
Mutual labels:  graphql, aws, serverless, lambda
Serverless Iam Roles Per Function
Serverless Plugin for easily defining IAM roles per function via the use of iamRoleStatements at the function level.
Stars: ✭ 311 (+187.96%)
Mutual labels:  aws, serverless, lambda, serverless-framework
Graphql Serverless
Sample project to guide the use of GraphQL and Serverless Architecture.
Stars: ✭ 28 (-74.07%)
Mutual labels:  graphql, aws, serverless, serverless-framework
Serverless Node Simple Image Resize
Simple image resize AWS lambda function
Stars: ✭ 74 (-31.48%)
Mutual labels:  aws, serverless, lambda, serverless-framework
Aws Auto Cleanup
Open-source application to programmatically clean your AWS resources based on a whitelist and time to live (TTL) settings
Stars: ✭ 276 (+155.56%)
Mutual labels:  aws, serverless, lambda, serverless-framework
Vulcain
Fast and idiomatic client-driven REST APIs.
Stars: ✭ 3,190 (+2853.7%)
Mutual labels:  api, graphql, rest-api, rest

JSON Serverless Renovate enabled Build Status License: MIT DeepScan grade aws provider

Trailer

Features

  • Create a REST API out of a json-server compatible JSON-File
  • Swagger UI integrated (Swagger spec automatically generated)
  • GrapqhiQL integrated (Graphql schema automatically generated)
  • Additional JSON File validations at startup
  • Readonly or Read/Write Mode (file stored in S3 Bucket)
  • Deployment in AWS:
  • Security:
    • Secured with https by default.
    • Optional: Use a generated API Key
  • Customization:
    • This solution written in Typescript can be easily extended for additional enhanced scenarios
      • adding user authentication (Here`s an example)
      • own custom domain
      • additional routes etc.

QuickStart

1. Install Solution

npm i -g json-serverless

2. Run local

  1. create a jsonserver-file sample e.g. db.json

    {
        "posts": [
          { "id": 1, "title": "json-server", "author": "typicode" },
          { "id": 2, "title": "test", "author": "yourAuthor" }
        ],
        "comments": [
          { "id": 1, "body": "some comment", "postId": 1 }
        ],
        "profile": { "name": "typicode" }
    }
    
  1. execute command

    jsonsls run db.json
    

3. Deploy api to AWS

  1. Verify that you have a AWS account and set appropriate credentials

  2. execute command

    jsonsls create-stack db.json {optional: STAGE}
    
  • a stack template folder will be created that contains the deployable serverless framework solution. You can use the serverless cli in this stack template folder.
  • When the deployment was successful you can see following output

    
    Service Information
    service: serverless-json-server
    stage: dev
    region: eu-central-1
    stack: serverless-json-server-dev
    api keys:
      serverless-json-server.dev: {API-KEY}
    endpoints:
      ANY - https://xxxxxx.execute-api.eu-central-1.amazonaws.com/dev/ <== {ENDPOINTURL}
      ANY - https://xxxxxxx.eu-central-1.amazonaws.com/dev/{proxy+}
    functions:
      app: serverless-json-server-dev-app
    layers:
      None
    Serverless: Removing old service artifacts from S3...
    

4. Test your Api

Open the {ENDPOINTURL}: https://xxxxxx.execute-api.eu-central-1.amazonaws.com/dev/ that you received as output

Features Relative Path Sample with Endpoint
Swagger UI /ui https://xxxxxx.execute-api.eu-central-1.amazonaws.com/dev/ui
Swagger Specification /api-spec https://xxxxxx.execute-api.eu-central-1.amazonaws.com/dev/api-spec
GraphiQL /graphql https://xxxxxx.execute-api.eu-central-1.amazonaws.com/dev/graphql
API Routes /api/{routes} https://xxxxxx.execute-api.eu-central-1.amazonaws.com/dev/api/posts

MIND: If you have set enableApiKeyAuth to true => SwaggerUI )

With Curl

  1. replace the url with the url provided by serverless (see above)
  2. replace the {API-KEY} with the key you get from serverless (see above)
  3. replace {route} at the end of the url e.g. with posts (default value)

Default Schema:

Default route is posts: (see db.json)
curl -H "Content-Type: application/json" https://xxxxxx.execute-api.eu-central-1.amazonaws.com/dev/api/posts

# or another route given in db.json file
curl -H "Content-Type: application/json" https://xxxxxx.execute-api.eu-central-1.amazonaws.com/dev/api/{route}

# with enableApiKeyAuth=true
curl -H "x-api-key: {API-KEY}" -H "Content-Type: application/json" https://xxxxxx.execute-api.eu-central-1.amazonaws.com/dev/api/{route}

What`s my {route} ? -> see json-server documentation

Architecture in AWS

Architecture

Customization

Examples

Please have a look at this example to see how you can add own middleware and authentication.
https://github.com/pharindoko/jsonsls-vue-cognito-demo

Update content of db.json

  1. update local db.json file in root directory with new values

  2. re-deploy the stack via serverless framework

     jsonsls update-stack
    
  3. delete db.json file in S3 Bucket

  4. Make a GET request against the root url https://xxxxxx.execute-api.eu-central-1.amazonaws.com/dev/api

curl -H "Content-Type: application/json" https://xxxxxx.execute-api.eu-central-1.amazonaws.com/dev/api

# with enableApiKeyAuth=true
curl -H "x-api-key: {API-KEY}" -H "Content-Type: application/json" https://xxxxxx.execute-api.eu-central-1.amazonaws.com/dev/api/{route}


=> With the next request a new db.json file will be created in the S3 Bucket

Adapt settings (in the stackfolder you can find this config under ./config/appconfig.json)

Attribute Description Type Default
readOnly Make API readonly - all API - write operations are forbidden (http 403)) string false
enableApiKeyAuth Make your routes private by using an additional ApiKey boolean false
enableJSONValidation validate JSON file at start boolean true
enableSwagger enable or disable Swagger (and related Graphql) features boolean true

Used Packages

Components

Develop & Contribute

PRs are welcome!

Overview

Please have a look into the makefile to get the understanding how this construct is built. There are components managed: (under /packages)

  • cli

    • built with oclif
    • main purpose is to enease the usage of the tool
    • creates a stack folder out of the template package
  • server

    • the core component of the solution
    • has json server implemented under the hood
    • components will be injected from outside into the library (storageadapter, swagger)
    • can be customized and used without the other parts (could be deployed with docker)
    • library can be used standalone as well (see example)
  • template

    • a serverless framework template

    • can be used standalone without the cli

        serverless create --template-url https://github.com/pharindoko/json-serverless/tree/master/packages/template
      
        npm i
        npm run build
        sls deploy
        sls offline
      

Installation

make install

Lerna will be used to manage the monorepo`s dependencies.

lerna bootstrap

Start the server component

make start-server

the json file will be loaded directly from your local filesystem. No AWS access is needed.

Start the template component

This part is using the serverless offline and is close to how the solution behaves in the cloud.

make start-template

the json file will be loaded directly from your local filesystem. No AWS access is needed.

Start the cli component

you should see a direct output of all local endpoints.

make start-cli

the json file will be loaded directly from your local filesystem. No AWS access is needed.

FAQ

Cannot use Swagger UI when enableApiKeyAuth is true

The apiKey is set in AWS API Gateway. This means all requests (even the standard route) need to use the API-KEY.

If you want to see the Swagger UI you need to add a plugin e.g. ModHeader to Chrome and add the needed headers:

  • Content-Type: application/json
  • x-api-key: {provided by sls info in the output after deployment}

ModHeader

I forgot the API-KEY I have set

Ensure you have credentials for AWS set.

sls info

Destroy the stack in the cloud

sls remove

I deployed the solution but I get back a http 500 error

Check Cloudwatch Logs in AWS - the issue should be describe there. Log has the same name as the stack that has been created.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].