Skip to content

Commit

Permalink
upgrade contentful deps
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Dec 6, 2024
1 parent 3e7ed69 commit 3e39af8
Show file tree
Hide file tree
Showing 11 changed files with 1,698 additions and 1,370 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.12.2
20.18.1
2,932 changes: 1,661 additions & 1,271 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,23 @@
"type": "module",
"license": "MIT",
"engines": {
"node": ">=20.12.2"
"node": ">=20.18.1"
},
"scripts": {
"clean": "rimraf ./public .greenwood",
"prisma": "prisma",
"lint": "eslint \"*.*js\" \"./src/**/**/*.*js\"",
"dev": "node --env-file=.env ./node_modules/@greenwood/cli/src/index.js develop",
"build": "node --env-file=.env ./node_modules/@greenwood/cli/src/index.js build",
"serve": "npm run clean && npm run build && greenwood serve",
"serve": "npm run clean && npm run build && node --env-file=.env ./node_modules/@greenwood/cli/src/index.js serve",
"studio": "prisma studio"
},
"dependencies": {
"@aws-sdk/client-cloudfront": "^3.58.0",
"@contentful/rich-text-html-renderer": "^15.11.1",
"@libsql/client": "^0.6.0",
"contentful": "^9.1.18"
},
"devDependencies": {
"@aws-sdk/client-cloudfront": "^3.58.0",
"@contentful/rich-text-html-renderer": "^17.0.0",
"@greenwood/cli": "^0.31.0-alpha.0",
"@libsql/client": "^0.6.0",
"contentful": "11.3.0",
"eslint": "^8.11.0",
"prisma": "^5.7.0",
"rimraf": "^5.0.5"
Expand Down
25 changes: 0 additions & 25 deletions src/http/get-albums/index.mjs

This file was deleted.

23 changes: 0 additions & 23 deletions src/http/get-artists/index.mjs

This file was deleted.

23 changes: 0 additions & 23 deletions src/http/get-posts/index.mjs

This file was deleted.

15 changes: 9 additions & 6 deletions src/pages/api/albums.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import mysql from 'mysql2/promise';
import { createClient } from '@libsql/client/web';

export async function handler (request) {
const params = new URLSearchParams(request.url.slice(request.url.indexOf('?')));
const id = params.has('id') ? params.get('id') : null;
const artistId = params.has('artistId') ? params.get('artistId') : null;
const connection = await mysql.createConnection(process.env.DATABASE_URL);
const [rows] = id
? await connection.execute('SELECT * FROM albums WHERE id = ?', [id])
const client = createClient({
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_TOKEN
});
const { rows } = id
? await client.execute({ sql: 'SELECT * FROM albums WHERE id = ?', args: [id] })
: artistId
? await connection.execute('SELECT * FROM albums WHERE artistId = ?', [artistId])
: await connection.execute('SELECT * FROM albums');
? await client.execute({ sql: 'SELECT * FROM albums WHERE artistId = ?', args: [artistId] })
: await client.execute('SELECT * FROM albums');

return new Response(JSON.stringify(rows), {
headers: new Headers({
Expand Down
13 changes: 8 additions & 5 deletions src/pages/api/artists.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import mysql from 'mysql2/promise';
import { createClient } from '@libsql/client/web';

export async function handler (request) {
const params = new URLSearchParams(request.url.slice(request.url.indexOf('?')));
const id = params.has('id') ? params.get('id') : null;
const connection = await mysql.createConnection(process.env.DATABASE_URL);
const [rows] = id
? await connection.execute('SELECT * FROM artists WHERE id = ?', [id])
: await connection.execute('SELECT * FROM artists');
const client = createClient({
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_TOKEN
});
const { rows } = id
? await client.execute({ sql: 'SELECT * FROM artists WHERE id = ?', args: [id] })
: await client.execute('SELECT * FROM artists');

return new Response(JSON.stringify(rows), {
headers: new Headers({
Expand Down
4 changes: 2 additions & 2 deletions src/pages/api/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
process.env.TZ = 'America/New_York';

// https://www.contentful.com/developers/docs/javascript/tutorials/using-js-cda-sdk/
import contentful from 'contentful';
import * as contentful from 'contentful';
import { documentToHtmlString } from '@contentful/rich-text-html-renderer';

const client = contentful.createClient({
Expand All @@ -18,7 +18,7 @@ export async function handler (request) {
const id = params.has('id') ? params.get('id') : null;
const tag = params.has('tag') ? params.get('tag') : null;

let events = (await client.getEntries('Event'))
let events = (await client.getEntries({ content_type: 'event' })) // eslint-disable-line camelcase
.items.map((event) => {
const { id, description, endTime, startTime, title, link } = event.fields;
const { tags = [] } = event.metadata;
Expand Down
13 changes: 8 additions & 5 deletions src/pages/api/posts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import mysql from 'mysql2/promise';
import { createClient } from '@libsql/client/web';

export async function handler (request) {
const params = new URLSearchParams(request.url.slice(request.url.indexOf('?')));
const id = params.has('id') ? params.get('id') : null;
const connection = await mysql.createConnection(process.env.DATABASE_URL);
const [rows] = id
? await connection.execute('SELECT * FROM posts WHERE id = ?', [id])
: await connection.execute('SELECT * FROM posts');
const client = createClient({
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_TOKEN
});
const { rows } = id
? await client.execute({ sql: 'SELECT * FROM posts WHERE id = ?', args: [id] })
: await client.execute('SELECT * FROM posts');

return new Response(JSON.stringify(rows), {
headers: new Headers({
Expand Down
3 changes: 2 additions & 1 deletion src/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
width: 10%;
height: 50px;
border-radius: 5px;
cursor: pointer;
}
details {
margin: 20px auto;
Expand All @@ -74,7 +75,7 @@
</head>

<body>
<h1>Resource Logger</h1>
<h1>Endpoint Debugger</h1>
<h2>Number of results: <span id="results"></span></h2>
<button id="albums">Albums</button>
<button id="artists">Artists</button>
Expand Down

0 comments on commit 3e39af8

Please sign in to comment.