Skip to content

H.4 — Standardize API filenames (closes #247) #322

@v-patel

Description

@v-patel

H.4 — Standardize API filenames (closes #247)

What's wrong

Mixed conventions in server/api/:

  • Some routes use index.ts and switch on event.node.req.method (e.g. announcement/index.ts, formGroup/index.ts, student/index.ts).
  • Others use Nuxt's method-suffix routing (account-settings.get.ts, account-settings.put.ts).
  • One uses a query parameter ?action=... to multiplex a dozen actions through one file (form/index.ts).

How to fix

Pick the Nuxt-native style: *.get.ts, *.post.ts, *.put.ts, *.delete.ts. Split each multi-method file:

  • announcement/index.tsannouncement/index.get.ts, announcement/index.post.ts
  • announcement/[id].tsannouncement/[id].delete.ts
  • formGroup/index.tsformGroup/index.get.ts, formGroup/index.put.ts
  • formSubmission/index.tsformSubmission/index.get.ts, formSubmission/index.post.ts
  • student/index.tsstudent/index.get.ts, student/index.post.ts
  • student/[id].tsstudent/[id].get.ts, student/[id].put.ts, student/[id].delete.ts

For form/index.ts (the action-multiplexer), the cleanest cure is to give each action its own file: form/groups.get.ts, form/groups.post.ts, form/forms.get.ts, etc. Larger refactor — possibly defer to a separate PR.

Important: do this after Group A (auth) so we're not chasing auth changes during the file move.

Files

  • All of server/api/

Severity

M.

Acceptance

  • No file in server/api/ switches on event.node.req.method.
  • All endpoints still work (manual test of the existing UI).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions