Skip to main content

Edit Route

OUTDATED

This page is part of the documentation for release V1.0. This documentation is outdated and V1.0 is no longer maintained. See index for the latest information.

The edit route renders the 'edit' pages that enable admins to create and modify articles, and other users. They return templated EJS sites that automatically fetch the requested resource's data and render it into editable HTML forms.

This set of routes is responsible for returning one of two possible options - both via the same EJS templates - for each form:

  1. An empty form for creating new object instances.
  2. A partially filled form for modifying existing instances.
routes/edit.js

The edit route is defined in /routes/edit.js and operates on the /api/edit API path.

Create new Blog Entry: (GET) /api/edit/blog

This route returns the blog entry creation form with no pre-filled fields. The form's template is implemented in /views/edit-blog.ejs.

This route is authenticated. It responds with an HTML page.

Request Parameters

ParameterDescription
JWT (cookie)(Required) Auth cookie

Example

curl -XGET --cookie "jwt=<AUTH COOKIE>" 'https://ufosc.org/api/edit/blog'

Modify Existing Blog Entry: (GET) /api/edit/blog/:id

This route returns an HTML form, filled with pre-existing blog post data, that enables an admit to modify the specified blog post. This is an authenticated route. It responds with an HTML page.

Request Parameters

ParameterDescription
ID (path)ID of blog post to modify
JWT (cookie)(Required) Auth cookie

Response

Responds with an HTML page of the blog modification form.

If the object ID is invalid, the following JSON error is returned:

application/json
{ "error": "The article you've tried to access no longer exists" }

If the object ID is valid but cannot be found, the following JSON error is returned:

application/json
{ "error": "Article not found" }

If the client is not authenticated, a 403 forbidden error will be returned.

Example

curl -XGET --cookie "jwt=<AUTH COOKIE>" 'https://ufosc.org/api/edit/blog/<BLOG ID HERE>'

Create new User: (GET) /api/edit/user

This route returns the user creation form with no pre-filled fields. The form's template is implemented in /views/edit-user.ejs.

This route is authenticated. It responds with an HTML page.

Request Parameters

ParameterDescription
JWT (cookie)(Required) Auth cookie

Example

curl -XGET --cookie "jwt=<AUTH COOKIE>" 'https://ufosc.org/api/edit/user'

Modify Existing User: (GET) /api/edit/user/:id

This route returns an HTML form, filled with pre-existing user data, that enables an admit to modify the specified user. This is an authenticated route. It responds with an HTML page.

Request Parameters

ParameterDescription
ID (path)ID of user to modify
JWT (cookie)(Required) Auth cookie

Response

Responds with an HTML page of the blog modification form.

If the object ID is invalid, the following JSON error is returned:

application/json
{ "error": "The user you've tried to access no longer exists" }

If the object ID is valid but cannot be found, the following JSON error is returned:

application/json
{ "error": "User not found" }

If the client is not authenticated, a 403 forbidden error will be returned.

Example

curl -XGET --cookie "jwt=<AUTH COOKIE>" 'https://ufosc.org/api/edit/user/<USER ID HERE>'