Code Monkey home page Code Monkey logo

stub's Introduction

Stub API

An application for create placeholder implementation of API responses which used as temporary substitute for the actual API. Build with Hono and redis. Checkout elysia for elysia stuff

Installation

Firstly, clone this repository

git clone https://github.com/doannc2212/stub.git
  1. Run with bun
cd stub
bun install
bun run dev
  1. Run with Docker
docker compose up -d

Then,

Stub is up on http://localhost:8000

How to use?

You need to attach cookie userId=${value} when request for api to know which user need data

  1. Create a new mock response
    Send a request to stub endpoint
POST baseUrl/create
Cookie: userId=john
{
	// request method
	"method": "GET",
	// requset path, which place right after baseUrl/api/
	"path": "/sample",
	// response body
	"data": {
		"id": 1,
		"name": "John Doe"
	},
	// response status
	"status": 200
}
  1. Clear mock response
POST baseUrl/clear
Cookie: userId=john
  1. Retrieve mock data
    Send request to baseUrl/api/ + path which you create before

Request:

GET baseUrl/api/sample
Cookie: userId=john

Response:

{
	"id": 1,
	"name": "John Doe"
}

FAQ

Stub api is not work after apply to my web application?

The stub API relies on cookies. To resolve this, follow these steps:

  1. Open Chrome DevTools.
  2. Navigate to the "Application" tab.
  3. Locate the cookies associated with your stub API endpoint.
  4. Set the "Same-Site" attribute of that cookies to "None".

stub's People

Contributors

doannc2212 avatar renovate[bot] avatar

Stargazers

 avatar

Watchers

 avatar

stub's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

bun
package.json
  • hono ^4.2.2
  • redis ^4.6.12
  • @types/bun ^1.0.0
  • @typescript-eslint/eslint-plugin ^7.0.0
  • @typescript-eslint/parser ^7.0.0
  • eslint ^8.0.0
docker-compose
compose.yaml
  • redis 7.2-alpine
dockerfile
Dockerfile
  • oven/bun 1

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.