Giter Club home page Giter Club logo

target-me's Introduction

Target Me

This is a service specialized in answering Http Status Codes so that we can test services. It offers the possibility of being able to return custom headers and even make the service have a specific timeout. The service is prepared to allow requests using CORS.

Another capability is the ability to answer custom status codes, which are defined in the status.json file. Feel free to make any changes or make a PR to modify it in the project.

Once the project is deployed, we will be able to see its documentation through its home page, which can be visited by simply visiting root domain ( localhost example )

Run application

The service has defined a series of Script commands to start and validate that everything is correct.

Command Description
npm run start Run sever with local certificates (https)
npm run start:insecure Run server without using local certificates (http)
npm run test Run jest
npm run test:all Run all tests
npm run test:util Run utilities tests
npm run test:service Run service tests
npm run test:api Run integration tests

Executable to run application in local:

npm run start

Dockerized

Official dockerhub repository: https://hub.docker.com/repository/docker/mfruiz/target-me

Command Description
docker build . -t mfruiz/target-me Create docker image
docker run -p 3000:3000 --name target-me mfruiz/target-me Use docker image
docker run -p 3000:3000 --name target-me -v /mnt/cert/:/mnt/cert mfruiz/target-me Start Up docker image with custom certificate path

Executable for command to build the docker image:

docker build . -t mfruiz/target-me

Http status codes

The purpose of the service is to receive a PathVariable which contains the expected status code and even to be able to send a list or range of codes that can be returned.

Examples:

Description url
200 with 2s Sleep https://localhost:3000/200?sleep=2
504 with 2s Sleep https://localhost:3000/504?sleep=2
statusCode 504 https://localhost:3000/503
StatusCode under 200 https://localhost:3000/199
No existing statusCode https://localhost:3000/1000
Random statusCode https://localhost:3000/random/200,203,500-504

Custom headers

In case we need to receive response headers from the service, we can do it by adding them in the request headers.

To do this, we must add a header that has the following prefix X-TargetMe-header-

Request header: X-TargetMe-header-foo: bar

Response header: foo: bar

Timeout parameter

The service has a single query param with which we can make it have a response delay of N seconds.

To do this operation is as simple as adding ?sleep=2 and we will be waiting 2 seconds

Certification

In the example I have added a self-signed certificate by me as an example on ./cert folder

This certificate will not be loaded in the Docker image, to add your own certificate, bind external route when running the docker image and indicate the path where the following files are located.

Important: We will need to have the 2 files with the same name that exist in the example. The service will validate the existence of these certificates and that they are valid to be able to start with the https scheme.

Disclaimer

The goal of this project is to improve my programming knowledge in Node.js, and for that, what better than using as an example of existing project https://httpstat.us/ created in another language (C#)

All coding has been done from zero and will be done in the most efficient way and using the least number of libraries necessary to do it.

In other words, it is my own alternative to 'httpstat.us' website/project for external connection testing.

I would like to thank the creators of Httpstat.us project ( AARON POWELL and TATHAM ODDIE ) for doing a great job that I think has helped many developers.

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.