Skip to content

Commit

Permalink
Merge pull request #29 from NewcastleRSE/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
markdturner authored Nov 15, 2023
2 parents f67bf40 + 1a0e515 commit 24a9c38
Show file tree
Hide file tree
Showing 12 changed files with 383 additions and 13 deletions.
20 changes: 20 additions & 0 deletions .strapi/client/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* This file was automatically generated by Strapi.
* Any modifications made will be discarded.
*/
import documentation from "@strapi/plugin-documentation/strapi-admin";
import i18N from "@strapi/plugin-i18n/strapi-admin";
import sentry from "@strapi/plugin-sentry/strapi-admin";
import usersPermissions from "@strapi/plugin-users-permissions/strapi-admin";
import importExportEntries from "strapi-plugin-import-export-entries/strapi-admin";
import { renderAdmin } from "@strapi/strapi/admin";

renderAdmin(document.getElementById("strapi"), {
plugins: {
documentation: documentation,
i18n: i18N,
sentry: sentry,
"users-permissions": usersPermissions,
"import-export-entries": importExportEntries,
},
});
62 changes: 62 additions & 0 deletions .strapi/client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en">
<!--
This file was automatically generated by Strapi.
Any modifications made will be discarded.
-->
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, viewport-fit=cover"
/>
<meta name="robots" content="noindex" />
<meta name="referrer" content="same-origin" />
<title>Strapi Admin</title>
<style>
html,
body,
#strapi {
height: 100%;
}
body {
margin: 0;
-webkit-font-smoothing: antialiased;
}
</style>
</head>
<body>
<div id="strapi"></div>
<noscript
><div class="strapi--root">
<div class="strapi--no-js">
<style type="text/css">
.strapi--root {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
background: #fff;
}

.strapi--no-js {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
font-family: helvetica, arial, sans-serif;
}
</style>
<h1>JavaScript disabled</h1>
<p>
Please
<a href="https://www.enable-javascript.com/">enable JavaScript</a>
in your browser and reload the page to proceed.
</p>
</div>
</div></noscript
>
</body>
</html>
10 changes: 9 additions & 1 deletion config/admin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
module.exports = ({ env }) => ({
apiToken: {
salt: env('API_TOKEN_SALT', 'example-salt')
},
auth: {
secret: env('ADMIN_JWT_SECRET', '9204ad6a287f37cef017b31743b4028a'),
secret: env('ADMIN_JWT_SECRET', 'example-secret'),
},
transfer: {
token: {
salt: env('TRANSFER_TOKEN_SALT', 'example-salt'),
}
},
});
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@
"luxon": "^3.3.0",
"mysql": "^2.18.1",
"pdf-lib": "^1.17.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "^5.2.0",
"strapi-plugin-import-export-entries": "^1.21.0",
"strapi-plugin-transformer": "^3.1.0"
"strapi-plugin-transformer": "^3.1.0",
"styled-components": "^5.2.1"
},
"author": {
"name": "Mark Turner"
Expand Down
11 changes: 10 additions & 1 deletion src/api/project/controllers/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,13 @@

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::project.project');
module.exports = createCoreController('api::project.project', ({ strapi }) => ({
async byHubSpotID(ctx) {
try {
ctx.body = await strapi.service('api::project.project').byHubSpotID(ctx.params.id);
} catch (err) {
ctx.body = err;
console.error(err);
}
}
}));
82 changes: 82 additions & 0 deletions src/api/project/documentation/1.0.0/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -503,5 +503,87 @@
],
"operationId": "delete/projects/{id}"
}
},
"/projects/hubspot/{id}": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProjectResponse"
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"500": {
"description": "Internal Server Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"tags": [
"Project"
],
"parameters": [
{
"name": "id",
"in": "path",
"description": "",
"deprecated": false,
"required": true,
"schema": {
"type": "number"
}
}
],
"operationId": "get/projects/hubspot/{id}"
}
}
}
60 changes: 58 additions & 2 deletions src/api/project/routes/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,61 @@
* project router.
*/

const { createCoreRouter } = require("@strapi/strapi").factories;
module.exports = createCoreRouter("api::project.project");
module.exports = {
routes: [
{
method: "GET",
path: "/projects",
handler: "project.find",
config: {
policies: [],
middlewares: [],
},
},
{
method: "GET",
path: "/projects/:id",
handler: "project.findOne",
config: {
policies: [],
middlewares: [],
},
},
{
method: "POST",
path: "/projects",
handler: "project.create",
config: {
policies: [],
middlewares: [],
},
},
{
method: "PUT",
path: "/projects/:id",
handler: "project.update",
config: {
policies: [],
middlewares: [],
},
},
{
method: "DELETE",
path: "/projects/:id",
handler: "project.delete",
config: {
policies: [],
middlewares: [],
},
},
{
method: "GET",
path: "/projects/hubspot/:id",
handler: "project.byHubSpotID",
config: {
policies: [],
middlewares: [],
},
}
]
}
20 changes: 18 additions & 2 deletions src/api/project/services/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,5 +632,21 @@ module.exports = createCoreService("api::project.project", ({ strapi }) => ({
console.error(err);
return null;
});
}
}));
},

async byHubSpotID(id) {
const { results } = await super.find({
filters: { hubspotID: id }
})

if(results.length === 0) {
return null
}
else if(results.length > 1) {
console.error(`More than one project found with HubSpot ID ${id}`)
return null
}
else {
return { data: results[0] }
}
}}));
Loading

0 comments on commit 24a9c38

Please sign in to comment.