This chapter covers:
- Generating backend code with Swagger Codegen
- Optimizing an OpenAPI definition for code generation
- Designing a Mongoose/MongoDB database based on the domain model
- Implementing a basic API operation in Node.js
José’s PetSitter team has created an OpenAPI definition for the API that connects the frontend with the backend. They have now reached the stage of the project where both developers are confident that the API is solid enough to start working on the implementation. In this chapter, we’ll join Nidhi, the backend developer, as she builds a backend that exposes the API that Max designed in chapter 10 and that she herself reviewed in chapter 11. While we’ll touch upon backend functionality like database persistence, our primary focus will be the process of going from API to code.
Our chosen backend technology is Node.js. Node.js is the server-side version of JavaScript. Of course there are a lot of other programming languages to choose from, such as Python, Ruby, Go (which we used for the FarmStall API in part 1), or PHP. We picked JavaScript because we expect most developers to have at least a basic grasp of the language syntax, even if it’s just from the client-side.