fix: read version from package.json, bump to 0.6.0, remove signup/free from OpenAPI spec
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 9m43s
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 9m43s
This commit is contained in:
parent
5b59a7a010
commit
2eca4e700b
5 changed files with 34 additions and 57 deletions
19
src/docs/__tests__/openapi.test.ts
Normal file
19
src/docs/__tests__/openapi.test.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { describe, it, expect } from 'vitest'
|
||||
import { openapiSpec } from '../openapi.js'
|
||||
|
||||
describe('OpenAPI Spec', () => {
|
||||
it('should include GET /v1/screenshot endpoint', () => {
|
||||
expect(openapiSpec.paths['/v1/screenshot']).toBeDefined()
|
||||
expect(openapiSpec.paths['/v1/screenshot'].get).toBeDefined()
|
||||
})
|
||||
|
||||
it('should include GET /v1/usage endpoint', () => {
|
||||
expect(openapiSpec.paths['/v1/usage']).toBeDefined()
|
||||
expect(openapiSpec.paths['/v1/usage'].get).toBeDefined()
|
||||
})
|
||||
|
||||
it('should NOT include /v1/signup/free endpoint', () => {
|
||||
const signupPath = openapiSpec.paths['/v1/signup/free']
|
||||
expect(signupPath).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
|
@ -1,7 +1,11 @@
|
|||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||
import { Request, Response } from 'express'
|
||||
import { createRequire } from 'module'
|
||||
import { healthRouter } from '../health.js'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
const pkg = require('../../../package.json')
|
||||
|
||||
// Mock dependencies
|
||||
vi.mock('../../services/browser.js', () => ({
|
||||
getPoolStats: vi.fn()
|
||||
|
|
@ -58,9 +62,10 @@ describe('Health Route', () => {
|
|||
await handler(req, res, vi.fn())
|
||||
|
||||
expect(mockGetPoolStats).toHaveBeenCalledOnce()
|
||||
|
||||
expect(res.json).toHaveBeenCalledWith({
|
||||
status: "ok",
|
||||
version: "0.1.0",
|
||||
version: pkg.version,
|
||||
uptime: expect.any(Number),
|
||||
browser: mockPoolStats
|
||||
})
|
||||
|
|
@ -115,7 +120,7 @@ describe('Health Route', () => {
|
|||
|
||||
expect(res.json).toHaveBeenCalledWith({
|
||||
status: "ok",
|
||||
version: "0.1.0",
|
||||
version: pkg.version,
|
||||
uptime: expect.any(Number),
|
||||
browser: mockPoolStats
|
||||
})
|
||||
|
|
@ -135,7 +140,7 @@ describe('Health Route', () => {
|
|||
|
||||
const responseCall = res.json.mock.calls[0][0]
|
||||
expect(responseCall).toHaveProperty('status', 'ok')
|
||||
expect(responseCall).toHaveProperty('version', '0.1.0')
|
||||
expect(responseCall).toHaveProperty('version', pkg.version)
|
||||
expect(responseCall).toHaveProperty('uptime')
|
||||
expect(responseCall).toHaveProperty('browser')
|
||||
})
|
||||
|
|
@ -178,7 +183,7 @@ describe('Health Route', () => {
|
|||
|
||||
expect(res.json).toHaveBeenCalledWith({
|
||||
status: "ok",
|
||||
version: "0.1.0",
|
||||
version: pkg.version,
|
||||
uptime: expect.any(Number),
|
||||
browser: mockPoolStats
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
import { Router } from "express";
|
||||
import { createRequire } from "module";
|
||||
import { getPoolStats } from "../services/browser.js";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const pkg = require("../../package.json");
|
||||
|
||||
export const healthRouter = Router();
|
||||
|
||||
/**
|
||||
|
|
@ -27,7 +31,7 @@ healthRouter.get("/", (_req, res) => {
|
|||
const pool = getPoolStats();
|
||||
res.json({
|
||||
status: "ok",
|
||||
version: "0.1.0",
|
||||
version: pkg.version,
|
||||
uptime: process.uptime(),
|
||||
browser: pool,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,57 +5,6 @@ import logger from "../services/logger.js";
|
|||
export const signupRouter = Router();
|
||||
|
||||
// Simple signup: email → instant API key (no verification for now)
|
||||
/**
|
||||
* @openapi
|
||||
* /v1/signup/free:
|
||||
* post:
|
||||
* tags: [Signup]
|
||||
* summary: Create a free account
|
||||
* description: Sign up with an email to get a free API key (100 screenshots/month).
|
||||
* operationId: signupFree
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required: [email]
|
||||
* properties:
|
||||
* email:
|
||||
* type: string
|
||||
* format: email
|
||||
* description: Your email address
|
||||
* example: "user@example.com"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: API key created
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* apiKey:
|
||||
* type: string
|
||||
* description: Your new API key
|
||||
* tier:
|
||||
* type: string
|
||||
* example: free
|
||||
* limit:
|
||||
* type: integer
|
||||
* example: 100
|
||||
* message:
|
||||
* type: string
|
||||
* 400:
|
||||
* description: Invalid email
|
||||
* content:
|
||||
* application/json:
|
||||
* schema: { $ref: "#/components/schemas/Error" }
|
||||
* 500:
|
||||
* description: Signup failed
|
||||
* content:
|
||||
* application/json:
|
||||
* schema: { $ref: "#/components/schemas/Error" }
|
||||
*/
|
||||
signupRouter.post("/free", async (req, res) => {
|
||||
const { email } = req.body;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue