@tenjuu99/blog 0.2.41 → 0.2.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ import helper from './helper.js'
2
+
3
+ const contentTypes = {
4
+ 'text': 'text/plain',
5
+ 'html': 'text/html',
6
+ 'css': 'text/css',
7
+ 'js': 'text/javascript',
8
+ 'jpg': 'image/jpeg',
9
+ 'jpeg': 'image/jpeg',
10
+ 'png': 'image/png',
11
+ 'webp': 'image/webp',
12
+ 'avif': 'image/avif',
13
+ 'svg': 'image/svg+xml',
14
+ 'json': 'application/json',
15
+ 'xml': 'application/xml',
16
+ 'rdf': 'application/rdf+xml',
17
+ 'rss': 'application/rss+xml',
18
+ }
19
+
20
+ const contentType = (ext) => {
21
+ if (helper['contentTypes']) {
22
+ const additionalContentTypes = helper['contentTypes']
23
+ if (additionalContentTypes[ext]) {
24
+ return additionalContentTypes[ext]
25
+ }
26
+ }
27
+ if (contentTypes[ext]) {
28
+ return contentTypes[ext]
29
+ }
30
+ return 'application/octet-stream'
31
+ }
32
+
33
+ export default contentType
package/lib/server.js CHANGED
@@ -4,34 +4,7 @@ import fs from 'node:fs'
4
4
  import { distDir, serverDir } from './dir.js'
5
5
  import { styleText } from 'node:util'
6
6
  import handle from './tryServer.js'
7
-
8
- const contentType = (ext) => {
9
- switch (ext) {
10
- case 'txt':
11
- return 'text/plain'
12
- case 'html':
13
- case 'css':
14
- return `text/${ext}`
15
- case 'js':
16
- return 'text/javascript'
17
- case 'jpeg':
18
- case 'png':
19
- case 'webp':
20
- case 'avif':
21
- return `image/${ext}`
22
- case 'jpg':
23
- return 'image/jpeg'
24
- case 'svg':
25
- return 'image/svg+xml'
26
- case 'xml':
27
- case 'json':
28
- return `application/${ext}`
29
- case 'rdf':
30
- return 'application/rdf+xml.rdf'
31
- default:
32
- return 'application/octet-stream'
33
- }
34
- }
7
+ import contentType from './contentType.js'
35
8
 
36
9
  const server = () => {
37
10
  return http.createServer(async (request, response) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenjuu99/blog",
3
- "version": "0.2.41",
3
+ "version": "0.2.42",
4
4
  "description": "blog template",
5
5
  "main": "index.js",
6
6
  "scripts": {