Skip to content

Commit dc5551b

Browse files
committed
feat: 🎉 Add new features to v0.0.8
Add changelog, fix issue with serving static content on root, set example, add build timestamp
1 parent 5b5ac2f commit dc5551b

File tree

5 files changed

+42
-5
lines changed

5 files changed

+42
-5
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Release 0.0.8
2+
3+
- Added CHANGELOG.md
4+
- Fix issue with serving static content. (Now you can serve static content on root by disabling root redirect to console via HLAMBDA_DISABLE_INITIAL_ROUTE_REDIRECT="true" )
5+
- Add example for the static serving of the content because `__dirname` is not available, `fileURLToPath(import.meta.url);` should be used.
6+
- Add version build number route. (GET /build-number)
7+
- Add timestamp to docker image on build `./image-build-timestamp.txt`

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ WORKDIR /usr/src/app
1515
# where available (npm@5+)
1616
COPY package*.json ./
1717

18-
RUN echo "Date: `date`" > ./version.txt
18+
# RUN echo "`date`" > ./image-build-time.txt
19+
RUN echo "`date +%s`" > ./image-build-timestamp.txt
1920

2021
RUN ["npm", "install"]
2122
# If you are building your code for production

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hlambda-core",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"description": "Hlambda core",
55
"type": "module",
66
"main": "src/index.js",
@@ -50,4 +50,4 @@
5050
"eslint-plugin-prettier": "^4.0.0",
5151
"nodemon": "^2.0.15"
5252
}
53-
}
53+
}

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,10 @@ const spinServer = async () => {
166166
app.use(cors());
167167

168168
if (!HLAMBDA_DISABLE_CONSOLE) {
169+
// Serve static
170+
app.use(express.static('public'));
171+
169172
if (!HLAMBDA_DISABLE_INITIAL_ROUTE_REDIRECT) {
170-
// Serve static
171-
app.use(express.static('public'));
172173
// Load main route (Should redirect to console)
173174
app.use('/', routeLanding);
174175
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import express from 'express';
2+
import asyncHandler from 'express-async-handler';
3+
4+
import { readFile } from 'fs/promises';
5+
import path from 'path';
6+
7+
// Define errors
8+
import { constants, isEnvTrue, getEnvValue } from './../../constants/index.js';
9+
import errors from './../../errors/index.js';
10+
11+
// Create express router
12+
const router = express.Router();
13+
14+
router.get(
15+
'/build-version',
16+
asyncHandler(async (req, res) => {
17+
const getBuildVersion = await readFile('./image-build-timestamp.txt', 'utf8')
18+
.then((fileData) => {
19+
return fileData;
20+
})
21+
.catch((error) => {
22+
return 'hotbuild';
23+
});
24+
res.status(200).send(getBuildVersion);
25+
})
26+
);
27+
28+
export default router;

0 commit comments

Comments
 (0)