Skip to content

Commit

Permalink
Merge pull request #97 from DIG-Network/release/v0.0.1-alpha.99
Browse files Browse the repository at this point in the history
Release/v0.0.1 alpha.99
  • Loading branch information
MichaelTaylor3D authored Nov 16, 2024
2 parents 3f54b65 + 45bc537 commit 8a9f161
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.0.1-alpha.99](https://github.com/DIG-Network/dig-content-server/compare/v0.0.1-alpha.98...v0.0.1-alpha.99) (2024-11-16)


### Features

* add urn headers ([b46d7d0](https://github.com/DIG-Network/dig-content-server/commit/b46d7d050584daca85c0bfffb2385f77e67f8e09))

### [0.0.1-alpha.98](https://github.com/DIG-Network/dig-content-server/compare/v0.0.1-alpha.97...v0.0.1-alpha.98) (2024-11-16)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dig-content-server",
"version": "0.0.1-alpha.98",
"version": "0.0.1-alpha.99",
"description": "",
"type": "commonjs",
"main": "./dist/index.js",
Expand Down
11 changes: 8 additions & 3 deletions src/controllers/storeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const getStoresIndex = async (req: Request, res: Response) => {

export const getKeysIndex = async (req: Request, res: Response) => {
// Extract variables from the request object
let { chainName, storeId, rootHash } = req as any;
let { chainName, storeId, rootHash, udi } = req as any;

try {
if (!rootHash) {
Expand Down Expand Up @@ -138,6 +138,7 @@ export const getKeysIndex = async (req: Request, res: Response) => {
res.setHeader("X-Synced", "false");
res.setHeader("X-Generation-Hash", rootHash);
res.setHeader("X-Store-Id", storeId);
res.setHeader("x-urn", udi);

const maxAgeInSeconds = 60 * 60 * 24 * 30; // Cache for 30 days
res.setHeader('Cache-Control', `public, max-age=${maxAgeInSeconds}`);
Expand Down Expand Up @@ -265,7 +266,7 @@ export const getKeysIndex = async (req: Request, res: Response) => {

// Controller for handling the /:storeId/* route
export const getKey = async (req: Request, res: Response) => {
let { chainName, storeId, rootHash } = req as any;
let { chainName, storeId, rootHash, udi } = req as any;
const catchall = req.params[0]; // This is the key name, i.e., the file path

const key = Buffer.from(decodeURIComponent(catchall), "utf-8").toString(
Expand Down Expand Up @@ -361,6 +362,7 @@ export const getKey = async (req: Request, res: Response) => {
res.setHeader("X-Store-Id", storeId);
res.setHeader("X-Key-Exists", "true");
res.setHeader("Content-Type", "application/json");
res.setHeader("x-urn", udi);

return res.json({
clsp: clspCode,
Expand All @@ -381,6 +383,7 @@ export const getKey = async (req: Request, res: Response) => {
res.setHeader("X-Store-Id", storeId);
res.setHeader("X-Key-Exists", "true");
res.setHeader("Content-Type", "application/json");
res.setHeader("x-urn", udi);

return res.json({
clsp: clspCode,
Expand All @@ -399,6 +402,7 @@ export const getKey = async (req: Request, res: Response) => {
res.setHeader("X-Generation-Hash", rootHash);
res.setHeader("X-Store-Id", storeId);
res.setHeader("X-Key-Exists", "true");
res.setHeader("x-urn", udi);

const maxAgeInSeconds = 60 * 60 * 24 * 30; // Cache for 30 days
res.setHeader('Cache-Control', `public, max-age=${maxAgeInSeconds}`);
Expand All @@ -422,7 +426,7 @@ export const getKey = async (req: Request, res: Response) => {
export const headKey = async (req: Request, res: Response) => {
try {
// @ts-ignore
let { storeId, rootHash } = req;
let { storeId, rootHash, udi } = req;
const catchall = req.params[0];

if (!rootHash) {
Expand Down Expand Up @@ -465,6 +469,7 @@ export const headKey = async (req: Request, res: Response) => {
res.setHeader("X-Generation-Hash", rootHash);
res.setHeader("X-Store-Id", storeId);
res.setHeader("X-Key-Exists", "true");
res.setHeader("x-urn", udi);

res.status(200).end(); // Respond with headers only, no content
} catch (error) {
Expand Down

0 comments on commit 8a9f161

Please sign in to comment.