rapid-tsGuide

School Example

This is a perfect example of how to create a School API, showcasing how to structure endpoints, reference IDs, and utilize enums efficiently.

import { RapidServer } from '@rapid-api/rapid-ts';

const options = {
	name: "school-api",
	port: 3000,
	prefix: "/api",
	endpoints: [
		{
			name: "students",
			methods: ["GET", "GET_BY_ID", "POST", "PUT", "DELETE"],
			objectReference: {
				name: "string", // Name of the student
				age: "number", // Age of the student
			},
		},
		{
			name: "classes",
			methods: ["GET", "GET_BY_ID", "POST", "PUT", "DELETE"],
			objectReference: {
				name: "string", // Name of the class
				students: ["id:students"], // List of students in this class
				teacher: "id:teachers", // Reference to the class teacher
			},
		},
		{
			name: "teachers",
			methods: ["GET", "GET_BY_ID", "POST", "PUT", "DELETE"],
			objectReference: {
				name: "string", // Name of the teacher
				subject: "enum:subjects", // Subject they teach
			},
		},
	],
	enums: {
		subjects: ["Math", "Science", "History", "English", "Physical Education"],
	},
};

const rapidServer = new RapidServer(options);
rapidServer.start();