I need to create RSS feed in my Angular 8 + Firebase app but i'm receiving discarding entity body for GET requests
warning in console. And after pending request data
is []
server.ts
app.get('/feed', function(req, res) {
const query = db.collection('news').orderBy('orderId').limit(3);
const filteredNews = [];
query.get().then(posts => {
posts.forEach(item => {
filteredNews.push(item.data());
});
return filteredNews;
}).then(data => {
const feedOptions = {
title: 'title',
description: 'description',
feed_url: 'https://barvy.today/rss.xml',
site_url: 'https://barvy.today',
image_url: 'https://barvy.today/assets/images/favicon.ico',
language: 'ua',
pubDate: data[0].utcDate,
};
const feed = new RSS(feedOptions);
data.forEach((item) => {
feed.item({
title: item.headingUa,
description: item.data[0].dataUa,
url: item.rssLink,
guid: item.id,
date: item.utcDate,
enclosure: { url: item.mainImg.url.toString().replace('&', '&'), type: 'image/jpeg' }
});
});
const xml = feed.xml({ indent: true });
res.set('Content-Type', 'text/xml');
res.send(xml);
});
});
webpack.config.js
const regex = /firebase/(app|firestore)/;
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
mode: 'none',
entry: {
server: './server.ts'
},
externals: {
'./dist/server/main': 'require("./server/main")'
},
target: 'node',
resolve: {
extensions: ['.ts', '.js']
},
optimization: {
minimize: false
},
output: {
// Puts the output at the root of the dist folder
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
module: {
noParse: /polyfills-.*.js/,
rules: [
{ test: /.ts$/, loader: 'ts-loader' },
{
test: /(\|/)@angular(\|/)core(\|/).+.js$/,
parser: { system: true },
},
]
},
plugins: [
new webpack.ContextReplacementPlugin(
/(.+)?angular(\|/)core(.+)?/,
path.join(__dirname, 'src'),
{}
),
new webpack.ContextReplacementPlugin(
/(.+)?express(\|/)(.+)?/,
path.join(__dirname, 'src'),
{}
)
]
};
With firebase-admin
app is not even building
question from:
https://stackoverflow.com/questions/65944099/cant-reach-firestore-from-server-ts-in-angular-8-application 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…