| 139 | }); |
| 140 | }; |
| 141 | function getContentType(a) { |
| 142 | switch (path.extname(a).toLowerCase()) { |
| 143 | case '.html': return 'text/html'; |
| 144 | case '.js': return 'text/javascript'; |
| 145 | case '.css': return 'text/css'; |
| 146 | case '.json': return 'application/json'; |
| 147 | case '.txt': return 'text/plain'; |
| 148 | case '.ico': return 'image/x-icon'; |
| 149 | case '.png': return 'image/png'; |
| 150 | case '.webp': return 'image/webp'; |
| 151 | case '.jpg': return 'image/jpeg'; |
| 152 | case '.jpeg': return 'image/jpeg'; |
| 153 | case '.gif': return 'image/gif'; |
| 154 | case '.svg': return 'image/svg+xml'; |
| 155 | default: return 'application/octet-stream'; |
| 156 | } |
| 157 | } |
| 158 | }; |
| 159 | use((req, res, next) => { |
| 160 | if (req.headers['content-type']?.includes('application/json')) { |