UNPKG

ts-express-kit

Version:

A TypeScript starter kit for building Express applications with best practices.

31 lines (30 loc) 1.56 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const AppError_1 = __importDefault(require("../../errors/AppError")); const test_model_1 = __importDefault(require("./test.model")); const http_status_1 = __importDefault(require("http-status")); const getTests = () => __awaiter(void 0, void 0, void 0, function* () { // if you are using a database, you would typically query the database here // For example, if using Mongoose: return Test.find(); const tests = yield test_model_1.default.tests; if (!tests) { throw new AppError_1.default(http_status_1.default.NOT_FOUND, "No tests found"); } return tests; }); const TestService = { getTests, }; exports.default = TestService;