GithubHelp home page GithubHelp logo

restapisample's Introduction

Sample with REST API

Intention

Just playing with the semantics of the APIs. I've been checking the standard and some resources on the internet:

Disclaimer

This repo is just for playing and testing, you won't find any test, best practices are applied softly.

Usage

  1. Build it.
make
  1. Run it (if you don't indicate the port it will run on 8080 by default).
PORT=<YOUR PORT> ./restapisample
  1. Curl it!
curl -X GET http://localhost:8080/jobs/01G8XJ74WR5FPT8GAWT44ECEGA
curl -X POST http://localhost:8080/jobs  -d '{"title": "the title, "company": "the company"}'
...

Results

image

image

Some thoughts

  • My model has not an ID but maybe it should have it. But, it introduces a new challenge, what happens if I want to modify the ID. Should the IDs be modifiable (I believe not!).
  • I am using ULIDs as ID. They have interesting properties https://blog.bitsrc.io/ulid-vs-uuid-sortable-random-id-generators-for-javascript-183400ef862c, but they are not human-friendly. Maybe a sort of "sku" should avoid this problem.
  • I was trying to use another in-memory key value datastore, but there weren't easy. I love Redis, but it depends on an external software. Maybe there is a better in-memory key value.

Conclusion

Are REST APIs easy? Probably, but sometimes reviewing the concepts is mandatory! Indeed, I was a bit confused about PUT / POST properties before this excercise.

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.