A simple REST server that presents a REST API similar to Zanata Server.
Fake Zanata Server is a tool to support developers who are making apps that communicate with a real Zanata server. It can also be used to try out proposed REST endpoints for Zanata during API design.
Requires Node.js.
To contribute to this server, create a branch or fork with your changes and submit a pull request for review.
Do not commit directly to master - it is not a maintainable practice. I will revert, rewrite or annihilate commits that are not reviewed through a pull request.
Install dependencies:
[prompt]$ npm install
...
Start the server with the default settings:
[prompt]$ npm start
...
REST endpoint listening at http://localhost:7878/zanata/rest, with latency 50..500
You can change some settings with command-line flags:
[prompt]$ npm start --port=1234 --latency=1000..5000 --path=rest --alloworigin="http://localhost:9000"
...
REST endpoint listening at http://localhost:1234/rest, with latency 1000..5000
minimum..maximum
. Default: 50..500Get resources from any of the endpoints listed under 'Endpoints' below:
[prompt]$ curl http://localhost:7878/zanata/rest/projects
[{
"id": "tiny-project",
"defaultType": "File",
"name": "Tiny Project",
"description": "A minimal project with a single version containing a single document.",
"sourceViewURL": null,
"sourceCheckoutURL": null,
"links": [{
"href": "p/tiny-project",
"rel": "self",
"type": "application/vnd.zanata.project+json"
}],
"iterations": null,
"status": "ACTIVE"
}
]
[prompt]$ curl http://localhost:7878/zanata/rest/projects/p/tiny-project
{
"id": "tiny-project",
"defaultType": "File",
"name": "Tiny Project",
"description": "A minimal project with a single version containing a single document.",
"sourceViewURL": "source-view-url",
"sourceCheckoutURL": "source-checkout-url",
"links": null,
"iterations": [{
"id": "1",
"links": [{
"href": "iterations/i/1",
"rel": "self",
"type": "application/vnd.zanata.project.iteration+json"
}],
"status": "ACTIVE",
"projectType": "File"
}],
"status": "ACTIVE"
}
[prompt]$ curl http://localhost:7878/zanata/rest/projects/p/tiny-project/iterations/i/1/r
[{
"name": "hello.txt",
"contentType": "text/plain",
"lang": "en-US",
"extensions": null,
"type": "FILE",
"revision": 1
}]
The data available from this mock endpoint will intentionally be minimal, so that it is easy to reason about.
A minimal project with a single version containing a single document.
A project that has plurals in its source document. Has a single version and document.
Here is a list of the available endpoint URLs. Some are experimental URLs for use in development, that are not yet present in the real Zanata server.
These exist on the real Zanata server
*Note: docId is encoded by replacing /
with ,
.
These do not exist on the real Zanata server, but may be implemented there in the future.
locales
[
{ "localeId": "en-US", "name": "English"},
{ "localeId": "fr", "name": "French"}
]
project/{projectSlug}
project/{projectSlug}/version/{versionSlug}
project/{projectSlug}/version/{versionSlug}/docs
project/{projectSlug}/version/{versionSlug}/doc/{encodedDocId*}
project/{projectSlug}/version/{versionSlug}/locales
project/{projectSlug}/version/{versionSlug}/doc/{docId}/status/{localeId}
/stats/project/{projectSlug}/version/{versionSlug}/doc/{encodedDocId*}/locale/{localeId}
endpoints for getting string details: source, translation, or both
POST /suggestions?from={sourceLocaleId}&to={transLocaleId}
PUT /trans/{localeId}
/{id}
to the URL, but
this is redundant and will not initially be implemented./user
/user/{username}
{
"username" : "username",
"email" : "email",
"name" : "display name",
"gravatarHash" : "gravatar hash"
}
project/{projectSlug}/permission/{localeId}
{
"write_translation" : true,
"review_translation" : false
}