MySQL Server example for JayStack OData V4 Server
With JayStack OData v4 Server you can build your own data endpoints without the hassle of implementing any protocol-level code. This framework binds OData v4 requests to your annotated controller functions, and compiles OData v4 compatible response. Clients can access services through OData-compliant HTTP requests. We recommend the JayData library for consuming OData v4 APIs.
This example uses JayStack OData V4 Server (odata-v4-server) and odata-v4-mysql repositories.
You can build your own OData v4 compatible service step-by-step by following this tutorial
Also there are sevaral other examples on JayStack OData V4 Server (odata-v4-server):
You have to create the database manually using these commands in server.ts:
DROP DATABASE IF EXISTS northwind;
CREATE DATABASE northwind;
USE northwind;
You have to customize the db connection options by editing connect.ts. By default, these are the options:
const config = {
host: "localhost",
user: "root",
password: "mysql"
};
By default, the server will listen on port
3306
therefore it is not set above.
npm run build
npm test
npm start
After starting the application (it will listen on localhost:3000
by default) you can generate / recreate the sample dataset
by submitting localhost:3000/initDb.
Alternatively if you start unit tests (npm test
) then the database will be initialized automatically.