A microservice for i18n json resources, providing a semver strategy to store and retrieve them.
The idea is to store project json resource files by language, and provide a version for them, so clients could retrieve documents for the desired project and language plus using semver semantic to provide version compatibility (useful on mobile where app version is hard to ensure).
We need a mongoose database :
docker run -d --name ec-mongo -p 27017:27017 mongo:4.0.18-xenial
npm install
npm start
docker build --no-cache -t semver_resource_server https://raw.githubusercontent.com/nmarsollier/semver_resource_server/master/Dockerfile
# Mac || Windows
docker run -it -d --name semver_resource_server -p 3000:3000 semver_resource_server
# Linux
docker run --add-host host.docker.internal:172.17.0.1 -it -d --name semver_resource_server -p 3000:3000 semver_resource_server
Once running backend documentation is exposed on localhost:3000
Everything is configured using environment args, see utils/environment.ts
curl --location --request POST 'http://localhost:3000/resources/hola_mundo/es/1.0.0' \
--header 'Content-Type: application/json' \
--data-raw '[
{
"key":"text_1",
"value":"Hola"
},
{
"key":"text_2",
"value":"Mundo 1.0.0"
}
]'
curl --location --request POST 'http://localhost:3000/resources/hola_mundo/es/1.0.1' \
--header 'Content-Type: application/json' \
--data-raw '[
{
"key":"text_1",
"value":"Hola"
},
{
"key":"text_2",
"value":"Mundo 1.0.1"
}
]'
curl --location --request POST 'http://localhost:3000/resources/hola_mundo/es/1.0.2' \
--header 'Content-Type: application/json' \
--data-raw '[
{
"key":"text_1",
"value":"Hola"
},
{
"key":"text_2",
"value":"Mundo 1.0.2"
}
]'
curl --location --request POST 'http://localhost:3000/resources/hola_mundo/es/1.2.0' \
--header 'Content-Type: application/json' \
--data-raw '[
{
"key":"text_1",
"value":"Hola"
},
{
"key":"text_2",
"value":"Mundo 1.2.0"
}
]'
curl --location --request POST 'http://localhost:3000/resources/hola_mundo/es/2.0.0' \
--header 'Content-Type: application/json' \
--data-raw '[
{
"key":"text_1",
"value":"Hola"
},
{
"key":"text_2",
"value":"Mundo 2.0.0"
}
]'
We can use any semver wildcard semver to retrieve documents. Examples :
curl --location --request GET 'http://localhost:3000/resources/hola_mundo/es/1.0.0'
curl --location --request GET 'http://localhost:3000/resources/hola_mundo/es/1.0.*'
curl --location --request GET 'http://localhost:3000/resources/hola_mundo/es/1.*'
curl --location --request GET 'http://localhost:3000/resources/hola_mundo/es/*'
curl --location --request GET 'http://localhost:3000/projects'
curl --location --request GET 'http://localhost:3000/resources/hola_mundo/versions'