DEV Community

Hyena
Hyena

Posted on

1

Sidecar pattern and Ursc

Sidecar pattern

https://github.com/rafapaezbas/ursc

The sidecar pattern is a distrbuted single node application pattern where a side application is used to extend functionality of the main application. Ursc can keep track of registration and login of users for another application.

Ursc

Ursc is a containerized sidecar application that help on keeping registration and login of user for any application.

Ursc has a very simple API:

/user/register

curl -v -X POST -H "Content-Type: application/json"  -d '{"name":"name","password":"password"}'  localhost:8083/user/register

Returns 201 if user is created, if there is already a user with the same name, response is code 403.

/user/login

curl -v -X POST -H "Content-Type: application/json"  -d '{"name":"name","password":"password"}'  localhost:8080/user/login

Returns 200 and a signed JWT token if credentials are correct, otherwise response will be code 403.

/user/check

curl -i -H "Authorization: Basic eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhYSIsImlhdCI6MTU5NzA3OTUwMCwiZXhwIjoxNTk3MDgzMTAwfQ.VCGsGjpAMEVUzQu2twamNUrbFeyjNECGjeq0nxlDlm1" -X GET localhost:8080/user/check

Check validity of the token sent in the Authorization header and returns 200 code with the name of user if the token is valid, if not response is 422.

Tutorial

If you want to deploy Ursc you also need a MongoDB instance. Make sure your database is up and running then have a look on the configuration file config.conf:

jwt_sign_secret=0123456
encryption_salt=0123456
mongodb_url=mongodb://mongodb:27017

Change the jwt signature and encryption salt to make your application saver. Then run init.sh, now you should have a Docker container running Ursc!

# Link mongodb container with alias "mongodb", expose application on port 8083
./init.sh -l mongodb:mongodb -p 8080 

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

Monitor more than uptime.

With Checkly, you can use Playwright tests and Javascript to monitor end-to-end scenarios in your NextJS, Astro, Remix, or other application.

Get started now!

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay