A lightweight newsreader built with SvelteKit, Elasticsearch, and TailwindCSS.
Project created from create-svelte
.
This project stores RSS feeds in Elasticsearch. You can use either a local Elasticsearch instance or an Elasticsearch Cloud deployment.
For local development, create a .env
file in the root of the project.
For production, set the environment variables in your hosting environment.
Add the following variables to the file:
SECRET_ELASTIC_USE_CLOUD=false # set to true if using Elasticsearch Cloud
SECRET_ELASTIC_HOST=http://localhost:9200 # local insecure Elasticsearch without SSL
SECRET_ELASTIC_CLOUD_ID=my_deployment_name # Elasticsearch Cloud deployment name
SECRET_ELASTIC_CLOUD_USERNAME=elastic # Elasticsearch Cloud username
SECRET_ELASTIC_CLOUD_PASSWORD=secret # Elasticsearch Cloud password
Run Elasticsearch in a Docker container:
docker run \
-p 9200:9200 \
-p 9300:9300 \
-e "discovery.type=single-node" \
-e "xpack.security.enabled=false" \
docker.elastic.co/elasticsearch/elasticsearch:8.10.0
(Only suitable for local development, without SSL.)
Once you've created a project and installed dependencies with pnpm install
, start a development server:
pnpm run dev
# or start the server and open the app in a new browser tab
pnpm run dev -- --open
The first time you run the app, the necessary Elasticsearch index, articles, does not exist.
To create the index and populate the articles, run the following command (or load the URL in your browser):
curl "http://localhost:5173/api/sync?secret=9Fl48lvMx4hED3MV4RqKQaKs76xOR3"
(pnpm run dev
must be running for this to work.)
To create a production version of your app:
pnpm run build
You can preview the production build with pnpm run preview
.
To deploy your app, you may need to install an adapter for your target environment.
You can use a cron job to sync the RSS feeds on a regular basis. Articles are upserted. The sync endpoint is protected by an insecure secret.
curl "http://localhost:5173/api/sync?secret=9Fl48lvMx4hED3MV4RqKQaKs76xOR3"
For Vercel, add a vercel.json file to the root of the project:
{
"crons": [
{
"path": "/api/sync?secret=9Fl48lvMx4hED3MV4RqKQaKs76xOR3",
"schedule": "0 * * * *"
}
]
}
This cron job will run once every hour at the start of the hour.