mini-services / miniurl Goto Github PK
View Code? Open in Web Editor NEWA production-ready URL shortener microservice.
License: MIT License
A production-ready URL shortener microservice.
License: MIT License
Publish as a plugin NPM package with programmatic usage, also suitable as Fastify & Express route plugins
@SnirShechter
Change Error
to ErrorConstructor
in /node_modules/fastify-error/index.d.ts
Allow picking a custom id (e.g http://url.sh/my-nice-link).
This route should be for admins only
Consider using https://draw.io
Background
The Storage service supports multiple drivers (connectors), which means it can use several databases as a storage target.
Task
Create a new driver which uses MongoDB and implement all of its functionalities similar to the other drivers (use the StorageDriver interface). Try to keep the file/folder structure as similar as possible to the other drivers for consistency.
Allow links to be related to certain users/groups/roles via headers/auth and used only by them
helm Makefile, docker Makefile etc.
Also consider just replacing it with existing GitHub Actions.
Ingress route should also take into account the port of baseRedirectUrl (not just host)
The task is to integrate e2e testing into the project, configure it, structure & design it and divide it into smaller tickets for others to assist.
Steps:
ava
for it)Tip:
See this for how to deploy a Postgres db in CI/CD tests. It might help.
Such as Code climate etc.
Should have a code coverage rating which will be shown as a tag on the README
For the routes documentation.
Should be directed towards either localhost or the demo
As an initial documentation and guide.
To be included:
Deployment CI/CD : run tests, build & push docker image, build & push helm, deploy docs & demo.
Test CI/CD: on PR, run tests, GitGuardian, some code quality tool and to be approved only by core team.
TODO: fix the .github/workflows, adjust the Makefile, setup Github Container Registry.
The MiniUrl storage service has multiple drivers with different storage targets. When running, the storage driver uses only one target, as configured by the user in the config module.
Even though only one driver is used, all the drivers are imported (loaded into memory), which results in unnecessary code loaded in production.
Make sure the drivers are imported only when needed.
storage/index.ts
(their types.ts
files can be imported as long as the types.ts
does not import the other driver files).storage/index.ts
with dynamic imports (`await import('..')) and use it only after checking which driver is picked.See the Node.js repo for a good example
In a managed Kubernetes environment. Also add a "deploy to demo" Github action.
How do we update the config live AND keep it up-to-date with other instances and the codebase config?
The problem is that changing configuration in the dashboard should be synced with the static config (environment variables etc.) that are injected into the process so that future deployments will stay in sync.
We need to implement a "graceful shutdown" upon receiving 'SIGINT', 'SIGTERM'
Our project also running docker. Unfortunately, sending these signals doesn't automatically translate the signals to a graceful shutdown of the running docker.
The solution to this problem is explained here:
https://snyk.io/blog/10-best-practices-to-containerize-nodejs-web-applications-with-docker/
Also, make sure our docker file follows the best practices mentioned in the article.
Relevant files:
src/index.js
you can also search for the comment "// Graceful shutdown" that will take you to the relevant location in the projects' folder
Allow the user to destroy the app, stop its functionality and cleanup since we might be using shared resources (database, etc.) - delete everything from the database and shutdown (removing a self-deployed database will be performed via helm uninstall)
Services, Routes, Config in particular.
The database is being accessed many times, which slows down the database and server quite heavily.
Make a list of all the non-live updates - incVisitCount, incInfoCount etc.
Design an asynchronous batch updating functionality for the frequent non-live updates. e.g incInfoCount should keep an in-memory count inside the driver and flush them all every 5-10 seconds.
NOTE Before the design, check if there's a better way to handle it in the connector libraries (e.g Knex
) instead of implementing our own.
After checking, there's no such functionality in Knex. The PostgresStorageDriver
should implement a batch-update mechanism for incInfoCount and incVisitCount. each of these should save its own cache and flush it every 10 seconds. Their usage in routes should also be non-blocking.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.