Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

rm unused last post endpoint

Blue Moused428c3b6b188
diff --git a/backend/apps/cloud/src/blog/blog.controller.ts b/backend/apps/cloud/src/blog/blog.controller.ts
index aca68a743..db8539ec4 100644
--- a/backend/apps/cloud/src/blog/blog.controller.ts
+++ b/backend/apps/cloud/src/blog/blog.controller.ts
@@ -19,12 +19,6 @@ export class BlogController {
return this.blogService.getSitemapFileNames(undefined, true)
}
- @Get('/last-post')
- @ApiResponse({ status: 200 })
- async getLastPost(): Promise<any> {
- return this.blogService.getLastPost()
- }
-
@Get('/:slug')
@ApiResponse({ status: 200 })
async getSlug(@Param('slug') slug: string): Promise<any> {
diff --git a/backend/apps/cloud/src/blog/blog.service.ts b/backend/apps/cloud/src/blog/blog.service.ts
index f0fe94dea..bc72cbd57 100644
--- a/backend/apps/cloud/src/blog/blog.service.ts
+++ b/backend/apps/cloud/src/blog/blog.service.ts
@@ -17,10 +17,8 @@ import { BLOG_POSTS_PATH, BLOG_POSTS_ROOT, redis } from '../common/constants'
const parseFrontMatter = require('front-matter')
const REDIS_SITEMAP_KEY = 'blog-sitemap'
-const REDIS_LAST_POST_KEY = 'blog-last-post'
// in seconds; 3600 seconds = 1 hour
const REDIS_SITEMAP_LIFETIME = 3600
-const REDIS_LAST_POST_LIFETIME = 900
// Removes first 10 characters from the string (i.e. 2023-10-07-)
const getSlugFromFilename = (filename: string) => filename.substring(11)
@@ -140,41 +138,6 @@ export class BlogService {
return post
}
- async getLastPost() {
- const rawRedisLastPost = await redis.get(REDIS_LAST_POST_KEY)
-
- if (rawRedisLastPost) {
- try {
- return JSON.parse(rawRedisLastPost)
- } catch (reason) {
- this.logger.error(
- `[getLastPost][JSON.parse] An error occured: ${reason}`,
- )
- }
- }
-
- const posts = (await getFileNames()).sort()
- const lastPost = _last(posts)
- const file = await fs.readFile(path.join(BLOG_POSTS_PATH, lastPost))
- const {
- attributes: { title },
- }: IParseFontMatter = parseFrontMatter(file.toString())
-
- const result = {
- handle: getSlugFromFilename(_replace(lastPost, /\.md$/, '')),
- title,
- }
-
- await redis.set(
- REDIS_LAST_POST_KEY,
- JSON.stringify(result),
- 'EX',
- REDIS_LAST_POST_LIFETIME,
- )
-
- return result
- }
-
async getSitemapFileNames(
category?: string,
infiniteRecursive?: boolean,
diff --git a/web/app/api/index.ts b/web/app/api/index.ts
index 127bced1a..0bb1578c5 100644
--- a/web/app/api/index.ts
+++ b/web/app/api/index.ts
@@ -1475,21 +1475,6 @@ export const getBlogPostWithCategory = (category: string, slug: string) =>
throw error
})
-export const getLastPost = (config?: AxiosRequestConfig) =>
- api
- .get('v1/blog/last-post', config)
- .then(
- (
- response,
- ): {
- title: string
- handle: string
- } => response.data,
- )
- .catch((error) => {
- throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
- })
-
export const unsubscribeFromEmailReports = (token: string) =>
api
.get(`user/unsubscribe/${token}`)