18 Node.Js Project Ideas for Beginner, Intermediate, and Advanced Programmers
It’s time for some Node.Js project ideas.
Node.Js is an asynchronous, event-driven JavaScript runtime designed to create applications in a lightweight, scalable format. With Node.Js, you can do pretty much everything that JavaScript could do, and more — and you can develop applications that operate on virtually any system.
Windows, Linux, Unix — Node.Js, like JavaScript, can run anywhere. And that’s what makes it such an alluring server environment for those who want to build applications in JavaScript.
If you’re interested in learning Node.Js, the best way is to get started with projects.
Beginner Node JS Project Ideas
1. Build a directory of books
Building a book directory is one of the classic Node.js project ideas. The command GET retrieves all the books, POST adds a new book, PUT updates an old book, and DELETE removes a book. This is an essential project for learning how the REST API functionality of Node.js works. It’s one of the first projects you should get started with — especially if you’ve never worked with REST API before.
Answer this: Once you’ve built your directory of books, what else could you use it for? You’ve created a database. How could you optimize it? Movies, television, and more? Are there better ways to categorize your system? How could you filter the items in your system? What other features could you add?
const express = require(‘express’);
const router = express.Router();
const books = require(‘./books.json’);
// Get all the books
router.get(‘/’, (req, res) => {
res.json(books);
});
// Get a specific book
router.get(‘/:id’, (req, res) => {
const { id } = req.params;
res.json(books.filter((ele) => ele.id === parseInt(id)));
});
router.post(‘/’, (req, res) => {
const body = req.body;
console.log(body);
books.push(body);
res.json({ message: ‘The book has been added’ });
});
router.put(‘/:id’, (req, res) => {
const { id } = req.params;
const body = req.body;
books.forEach((book, index) => {
if (book.id === parseInt(id)) {
books[index] = body;
}
});
res.json({ message: `The book with ID ${id} has been updated` });
// res.json(books);
});
router.delete(‘/:id’, (req, res) => {
const { id } = req.params;
books.forEach((book, index) => {
if (book.id === parseInt(id)) {
books.splice(index);
}
});
res.json({ message: `Book with id #${id} has been deleted` });
});
module.exports = router;
Last Updated May 2024
Learn from real NodeJS experts! Includes REALLY Advanced NodeJS. Express, GraphQL, REST, MongoDB, SQL, MERN + much more | By Andrei Neagoie, Adam Odziemkowski
Explore Course2. Create your own chat app.
This basic project will show you how to develop your own real-time chat app. More than that, it will also highlight an important concept: Often, Node.js alone isn’t enough to complete a project. If you’re making a chat app, it’s likely you will need Express.js and some other packages and libraries, too.
Answer this: How many people can talk in your chat app? How many people would you be able to add into a chatroom before it failed to scale? How would you test the load in a chatroom? Could you open additional chatrooms as the load is reached and exceeded to balance your load yourself?
Github: nodejs-chat-app (owanhunte)
3. Develop a user login system
In nearly any application, you’ll need a basic users system. Develop it now so you can use it with some of your other project ideas. You’ll learn about how to use a token for the user identification process, methods get post put, and more. You’ll learn about authentication systems, database management, and managing the REST API.
Answer this: Once you’re done designing your user login system, how would you add two-factor authentication? What about multi-factor authentication? If you wanted to link it to a Gmail or Facebook login, would you know how to tie in these third-party authentication systems?
const express = require(‘express’);
const expressLayouts = require(‘express-ejs-layouts’);
const mongoose = require(‘mongoose’);
const passport = require(‘passport’);
const flash = require(‘connect-flash’);
const session = require(‘express-session’);
const app = express();
// Passport Config
require(‘./config/passport’)(passport);
// DB Config
const db = require(‘./config/keys’).mongoURI;
// Connect to MongoDB
mongoose
.connect(
db,
{ useNewUrlParser: true ,useUnifiedTopology: true}
)
.then(() => console.log(‘MongoDB Connected’))
.catch(err => console.log(err));
// EJS
app.use(expressLayouts);
app.set(‘view engine’, ‘ejs’);
// Express body parser
app.use(express.urlencoded({ extended: true }));
// Express session
app.use(
session({
secret: ‘secret’,
resave: true,
saveUninitialized: true
})
);
// Passport middleware
app.use(passport.initialize());
app.use(passport.session());
// Connect flash
app.use(flash());
// Global variables
app.use(function(req, res, next) {
res.locals.success_msg = req.flash(‘success_msg’);
res.locals.error_msg = req.flash(‘error_msg’);
res.locals.error = req.flash(‘error’);
next();
});
// Routes
app.use(‘/’, require(‘./routes/index.js’));
app.use(‘/users’, require(‘./routes/users.js’));
const PORT = process.env.PORT || 5000;
app.listen(PORT, console.log(`Server running on ${PORT}`));
4. Send emails with Node.JS
Sending emails with Node.js should be a breeze — the actual mailing functionality is pretty simple. But for this system, you should focus on the development of the website itself. Create a sleek, high-performing single-page application with a beautiful email GUI.
Answer this: What if you wanted to send emails to a given email directory, such as a directory of students and teachers? Could you create a database and pull information from it regarding specific users that can be emailed? How would you check to see whether the emails were valid? Hint: regular expressions. How could you prevent a DDoS attack?
Github: Nodemailer (Nodemailer)
5. Build a web scraper
Need some data from a website? A web scraper is a good step. Let’s say you wanted to aggregate movie reviews. You’d need to build a web scraper to get that information. Or maybe you want a news aggregation service. You’d need to build a web scraper. Create a scraper that can pull specific information from given sites.
Answer this: What could you use a web scraper for? Think about a project that you might want to build, pull the data from your web scraper, then properly format, analyze, and modify it for your own site. Be careful! Make sure you aren’t scraping any privileged information and that everything you’re scraping is fair use.
Github: Scrape-It (IonicaBizau)
6. Create a Discord bot with Node.js
What’s the most popular location for real time chats today? Discord and Slack, of course. Discord has a lot of bots out there that make the process of chatting easier. You can experiment with creating a Discord bot with Node.js to improve the utility of your servers. For instance, a project management bot for a productivity server.
Answer this: If you could add one feature to Discord, what would it be? How can you add this functionality through an app, rather than through modifying Discord itself? Are there Discord bots that have similar functionality? How would you make these Discord bots better? And how would you start developing a framework?
Github: Onyx (silvia-odwyer)
7. Make a random number generator
It’s surprising how many things, like games, are actually built on a random number generator. This may seem like a simple little project, but it’s a great way to warm up, get started, and get familiar with the way that Node.js architecture works. Create a random number generator that will generate a given number to a certain precision.
Answer this: Tabletop games use dice: 4-sided, 6-sided, 8-sided, 10-sided, 12-sided, and 20-sided. How could you create a random number generator that would generate a given number of dice, such as rolling 6d6 (six 6-sided dice) or 20d8 (twenty 8-sided dice)? Could you make it so that it has a clean GUI?
/**
* Seedable random number generator functions.
* @version 1.0.0
* @license Public Domain
*
* @example
* var rng = new RNG(‘Example’);
* rng.random(40, 50); // => 42
* rng.uniform(); // => 0.7972798995050903
* rng.normal(); // => -0.6698504543216376
* rng.exponential(); // => 1.0547367609131555
* rng.poisson(4); // => 2
* rng.gamma(4); // => 2.781724687386858
*/
/**
* @param {String} seed A string to seed the generator.
* @constructor
*/
function RC4(seed) {
this.s = new Array(256);
this.i = 0;
this.j = 0;
for (var i = 0; i < 256; i++) {
this.s[i] = i;
}
if (seed) {
this.mix(seed);
}
}
/**
* Get the underlying bytes of a string.
* @param {string} string
* @returns {Array} An array of bytes
*/
RC4.getStringBytes = function(string) {
var output = [];
for (var i = 0; i < string.length; i++) {
var c = string.charCodeAt(i);
var bytes = [];
do {
bytes.push(c & 0xFF);
c = c >> 8;
} while (c > 0);
output = output.concat(bytes.reverse());
}
return output;
};
RC4.prototype._swap = function(i, j) {
var tmp = this.s[i];
this.s[i] = this.s[j];
this.s[j] = tmp;
};
/**
* Mix additional entropy into this generator.
* @param {String} seed
*/
RC4.prototype.mix = function(seed) {
var input = RC4.getStringBytes(seed);
var j = 0;
for (var i = 0; i < this.s.length; i++) {
j += this.s[i] + input[i % input.length];
j %= 256;
this._swap(i, j);
}
};
/**
* @returns {number} The next byte of output from the generator.
*/
RC4.prototype.next = function() {
this.i = (this.i + 1) % 256;
this.j = (this.j + this.s[this.i]) % 256;
this._swap(this.i, this.j);
return this.s[(this.s[this.i] + this.s[this.j]) % 256];
};
/**
* Create a new random number generator with optional seed. If the
* provided seed is a function (i.e. Math.random) it will be used as
* the uniform number generator.
* @param seed An arbitrary object used to seed the generator.
* @constructor
*/
function RNG(seed) {
if (seed == null) {
seed = ” + Math.random() + Date.now();
} else if (typeof seed === “function”) {
// Use it as a uniform number generator
this.uniform = seed;
this.nextByte = function() {
return ~~(this.uniform() * 256);
};
seed = null;
} else if (Object.prototype.toString.call(seed) !== “[object String]”) {
seed = JSON.stringify(seed);
}
this._normal = null;
if (seed) {
this._state = new RC4(seed);
} else {
this._state = null;
}
}
/**
* @returns {number} Uniform random number between 0 and 255.
*/
RNG.prototype.nextByte = function() {
return this._state.next();
};
/**
* @returns {number} Uniform random number between 0 and 1.
*/
RNG.prototype.uniform = function() {
var BYTES = 7; // 56 bits to make a 53-bit double
var output = 0;
for (var i = 0; i < BYTES; i++) {
output *= 256;
output += this.nextByte();
}
return output / (Math.pow(2, BYTES * 8) – 1);
};
/**
* Produce a random integer within [n, m).
* @param {number} [n=0]
* @param {number} m
*
*/
RNG.prototype.random = function(n, m) {
if (n == null) {
return this.uniform();
} else if (m == null) {
m = n;
n = 0;
}
return n + Math.floor(this.uniform() * (m – n));
};
/**
* Generates numbers using this.uniform() with the Box-Muller transform.
* @returns {number} Normally-distributed random number of mean 0, variance 1.
*/
RNG.prototype.normal = function() {
if (this._normal !== null) {
var n = this._normal;
this._normal = null;
return n;
} else {
var x = this.uniform() || Math.pow(2, -53); // can’t be exactly 0
var y = this.uniform();
this._normal = Math.sqrt(-2 * Math.log(x)) * Math.sin(2 * Math.PI * y);
return Math.sqrt(-2 * Math.log(x)) * Math.cos(2 * Math.PI * y);
}
};
/**
* Generates numbers using this.uniform().
* @returns {number} Number from the exponential distribution, lambda = 1.
*/
RNG.prototype.exponential = function() {
return -Math.log(this.uniform() || Math.pow(2, -53));
};
/**
* Generates numbers using this.uniform() and Knuth’s method.
* @param {number} [mean=1]
* @returns {number} Number from the Poisson distribution.
*/
RNG.prototype.poisson = function(mean) {
var L = Math.exp(-(mean || 1));
var k = 0, p = 1;
do {
k++;
p *= this.uniform();
} while (p > L);
return k – 1;
};
/**
* Generates numbers using this.uniform(), this.normal(),
* this.exponential(), and the Marsaglia-Tsang method.
* @param {number} a
* @returns {number} Number from the gamma distribution.
*/
RNG.prototype.gamma = function(a) {
var d = (a < 1 ? 1 + a : a) – 1 / 3;
var c = 1 / Math.sqrt(9 * d);
do {
do {
var x = this.normal();
var v = Math.pow(c * x + 1, 3);
} while (v <= 0);
var u = this.uniform();
var x2 = Math.pow(x, 2);
} while (u >= 1 – 0.0331 * x2 * x2 &&
Math.log(u) >= 0.5 * x2 + d * (1 – v + Math.log(v)));
if (a < 1) {
return d * v * Math.exp(this.exponential() / -a);
} else {
return d * v;
}
};
/**
* Accepts a dice rolling notation string and returns a generator
* function for that distribution. The parser is quite flexible.
* @param {string} expr A dice-rolling, expression i.e. ‘2d6+10’.
* @param {RNG} rng An optional RNG object.
* @returns {Function}
*/
RNG.roller = function(expr, rng) {
var parts = expr.split(/(\d+)?d(\d+)([+-]\d+)?/).slice(1);
var dice = parseFloat(parts[0]) || 1;
var sides = parseFloat(parts[1]);
var mod = parseFloat(parts[2]) || 0;
rng = rng || new RNG();
return function() {
var total = dice + mod;
for (var i = 0; i < dice; i++) {
total += rng.random(sides);
}
return total;
};
};
/* Provide a pre-made generator instance. */
RNG.$ = new RNG();
8. Build a personal website
Here’s a project you can create that will help you in the future: Build a personal website and a personal portfolio. Node.js excels at single-page applications. To make it even better, create a database with your personal information in it, rather than hard-coding the data — this will give you more experience with your database management and pulls. It will also make your website customizable.
Answer this: What if you wanted to customize the theme? What if you wanted the users to be able to move from “light mode” to “dark mode” on your site with the click of a button? What if you wanted to add multiple pages, such as a separate portfolio page with a gallery view? Or insert a video?
Github: Personal-Website (DevonCrawford)
Intermediate Node JS Project Ideas
9. Create a video streaming platform
Use Node.js and Express.js to create a video player and a platform around it. Use a database to keep track of the videos and a file repository to keep the videos stored. Compress the videos as needed when you store them on your server. Make sure the videos get tagged and categorized correctly so your application can tell what each is about.
Answer this: What if you wanted multiple users to be able to upload video streams? Could you do this with your previous user login project? Could you make it so that users can explore the entire archive? Using categories and tags, could you make it possible for users to find “recommended” videos based on what they’ve seen before?
Github: video-streaming-example (bootstrapping microservices)
10. Build a project management app
Everyone needs a little project management in their lives. With Node.js, create a project management app. That includes tasks, projects, and individuals who need to complete them. Who knows, you could use your project management app to manage the projects that you’re already working on. Your project management app should allow you to mark tasks as complete and should track deadlines.
Answer this: What if you wanted multiple people to use this app? Can you support projects assigned to different people? To multiple people? Can you create an inbox that includes all the tasks that one person needs to do, regardless of the project? Can you alert them in a message box when a project is late?
Github: fullstack_Project_Management_App (calvin-puram)
11. Create an NLP chatbot
In addition to creating a real time chat application, why not consider an NLP chatbot? This uses neurolinguistic programming to determine what a user wants information about. You can create an NLP chatbot that, for instance, refers people to the right tier of customer service, or helps them make, cancel, and edit orders. You begin with a blank slate and then trade the app.
Answer this: Eliza was famously one of the first chatbots, which replicated a human therapist, and sought to “understand” what people were saying. How could you create Eliza with an NLP chatbot in Node.js? What would you do to make it seem as though Eliza was “real” if she didn’t understand something said to her?
const { Recognizer, Language } = require(‘node-nlp’);
const trainingNLP = require(‘./training/_training’);
const THRESHOLD = 0.7;
let incrementIdConversation = true;
let idConversation = 0;
const Bot = class {
constructor(language, fallbackLang) {
this.recognizer = new Recognizer();
this.languageGuess = new Language();
this.languages = language;
this.manager = this.recognizer.nlpManager;
this.manager.addLanguage(language);
this.fallbackLocale = fallbackLang;
console.log(‘Bot started!’);
}
async trainModel() {
console.log(‘Training started…’);
await trainingNLP(this.manager);
await this.manager.train()
console.log(‘Training finished!’);
}
saveModel(filename) {
console.log(‘Model saved!’);
this.manager.save(filename);
}
loadModel(filename) {
if (fs.existsSync(filename)) {
console.log(‘Model loaded from disk!’);
this.manager.load(filename);
} else {
console.log(‘The model requested doesn\’t exists’)
}
}
async sendAnswer(query) {
var message = this.buildMessage(query);
var result = await this.recognizer.recognize(message);
incrementIdConversation = !(result && result.slotFill);
const answer = result.score > THRESHOLD && result.answer ? result.answer : (result.locale === ‘es’) ? “Lo siento, no te he entendido” : “Sorry, I don’t understand”;
console.log(result);
return { locale: result.locale, message: answer };
}
buildMessage(query) {
if (incrementIdConversation === true) idConversation++;
return { locale: this.fallbackLocale, message: { address: { conversation: { id: ‘conversation_’ + idConversation } }, text: query } };
}
}
module.exports = Bot
12. Make a drawing app
Node.js’s online functions are where it really shines. This project is creating a drawing app, which is collaborative in nature; multiple people can be working on the same “canvas” at once. This isn’t just for fun. It can provide a “whiteboard” tool for those who are collaborating with each other from home.
Answer this: How could you prevent other users from being able to modify each other’s work? Perhaps by creating a separate layer for each work? How could you save the collaborative efforts once they’re done? What are some additional features, like a live chat, that you could add to this drawing application to make it feel more complete?
Github: DrawTogether (saikat)
13. Develop an RSS feed reader
It’s time to read an RSS feed. This is a typical learning project because RSS feeds are extremely specific in terms of formatting, and because you need to be able to process that formatting into your application. Create an RSS subscription and feed reader that can support multiple RSS feeds.
Answer this: Could you make it so that your RSS feed is customizable? Try to make it so that users can drag and drop different feeds to reorganize them, or remove and add feeds instantly rather than it being hard-coded. Add the function to add different themes to the RSS feeds to make them look more attractive.
import { TypedEmitter } from ‘tiny-typed-emitter’;
import { default as FeedMe, FeedItem } from ‘feedme’;
import NewsEmitter from ‘newsemitter’;
import miniget from ‘miniget’;
import zlib from ‘zlib’;
// Used for the skipdays tag.
const DAYS = [‘sunday’, ‘monday’, ‘tuesday’, ‘wednesday’,
‘thursday’, ‘friday’, ‘saturday’];
export interface Options {
interval?: number;
forceInterval?: boolean;
autoStart?: boolean;
emitOnStart?: boolean;
lastDate?: null | string;
history?: string[];
maxHistory?: number;
skipHours?: boolean;
hoursToSkip?: number[];
skipDays?: boolean;
daysToSkip?: string[];
requestOpts?: miniget.Options;
}
export type DefaultOptions = Required<Options>;
interface FeedSubEvents {
‘error’: (err: Error) => void;
‘item’: (item: FeedItem) => void;
‘items’: (items: FeedItem[]) => void;
}
export { FeedItem } from ‘feedme’;
export default class FeedSub extends TypedEmitter<FeedSubEvents> {
public feed: string;
public options: DefaultOptions;
public news: NewsEmitter;
public getOpts: miniget.Options & { headers: Record<string, string> };
private _first: boolean;
private _intervalid: number;
/**
* @constructor
* @param {string} feed
* @param {!Object} options
*/
constructor(feed: string, options?: Options) {
super();
this.feed = feed;
this.options = Object.assign({
interval : 10,
forceInterval : false,
autoStart : false,
emitOnStart : false,
lastDate : null,
history : [],
maxHistory : 10,
skipHours : false,
hoursToSkip : null,
skipDays : false,
daysToSkip : null,
requestOpts : {},
}, options);
// Create news emitter.
this.news = new NewsEmitter({
maxHistory: this.options.maxHistory,
manageHistory: true,
identifier: (item: any[]) => {
let feedItem = item[0];
return [
feedItem.title,
feedItem.link,
feedItem.pubdate,
feedItem.published,
feedItem.updated
].join(‘,’);
}
});
this.news.addHistory(‘item’, this.options.history);
this._first = (this.news.history.get(‘item’) as Set<string>).size === 0;
this.getOpts = Object.assign({
headers: {} as Record<string, string>,
acceptEncoding: {
gzip: () => zlib.createGunzip(),
deflate: () => zlib.createInflate(),
},
}, this.options.requestOpts);
if (this.options.autoStart) {
this.start(true);
}
}
/**
* Start calling the read function on interval.
*
* @param {boolean} readOnStart
*/
start(readOnStart?: boolean) {
this.stop();
let ms = this.options.interval * 60000;
this._intervalid = setInterval(this.read.bind(this), ms);
if (readOnStart) {
this.read();
}
}
/**
* Stop interval if any
*/
stop() {
clearInterval(this._intervalid);
}
/**
* Reads feed and determines if there are any new items
* emits new items through event `item`
* if there are new items, emits `items` event at end with all items
*
* if callback is given, calls callback with all new items
* even when there are 0.
*
* @param {!Function(!Error, Array.<Object>)} callback
*/
read(callback?: (err: null | Error, items?: FeedItem[]) => void) {
let ended = false;
let req: miniget.Stream;
let items: FeedItem[] = [];
let newItems: FeedItem[] = [];
let sortOrder = 0;
const error = (err: Error) => {
ended = true;
this._first = false;
if (typeof callback === ‘function’) {
callback(err);
} else {
this.emit(‘error’, err);
}
req.destroy();
};
const success = () => {
if (ended) { return; }
ended = true;
if (sortOrder <= 0) {
newItems.reverse();
}
this.news.addHistory(‘item’, newItems.map((item) => [item]));
if (this._first && !this.options.emitOnStart) {
newItems = [];
}
newItems.forEach(item => this.emit(‘item’, item));
this.emit(‘items’, newItems);
if (req) {
req.destroy();
}
if (typeof callback === ‘function’) {
callback(null, newItems);
}
};
// If skipHours or skipDays are enabled and feed provides hours/days
// to skip and it’s currently one of those hours/days, abort.
const now = new Date();
const shouldSkip = () => {
return (
(!this._first || !this.options.emitOnStart) &&
(this.options.hoursToSkip || this.options.daysToSkip)
) && (
(this.options.hoursToSkip &&
this.options.hoursToSkip.indexOf(now.getHours()) !== -1) ||
(this.options.daysToSkip &&
this.options.daysToSkip.some((day) => {
return day.toLowerCase() === DAYS[now.getDay()];
})
)
);
};
if (shouldSkip()) {
return success();
}
req = miniget(this.feed, this.getOpts);
req.on(‘response’, (res) => {
// Check if not modified code is sent back
// in this case, the body will be empty.
if (res.statusCode === 304) {
return success();
}
// Check headers for conditional get.
if (res.headers[‘last-modified’]) {
this.getOpts.headers[‘If-Modified-Since’] = res.headers[‘last-modified’];
}
if (res.headers.etag) {
this.getOpts.headers[‘If-None-Match’] = res.headers.etag;
}
// Save date.
let date: string;
let getdate = (text: string) => date = text;
// Create feed parser.
const parser = new FeedMe();
parser.on(‘error’, error);
// Try to get date from one of the fields.
parser.once(‘pubdate’, getdate);
parser.once(‘lastbuilddate’, getdate);
parser.once(‘updated’, getdate);
// Change interval time if ttl available.
if (!this.options.forceInterval) {
parser.once(‘ttl’, (minutes) => {
minutes = parseInt(minutes, 10);
// Only update if ttl is longer than requested interval.
if (minutes > this.options.interval) {
this.options.interval = minutes;
if (this.options.autoStart) {
this.start(false);
}
}
});
}
// Listen for skipHours if enabled.
if (this.options.skipHours && !this.options.hoursToSkip) {
parser.once(‘skiphours’, (data) => {
this.options.hoursToSkip =
[].concat(data.hour).map(h => parseInt(h, 10));
});
}
// Listen for skipDays if enabled.
if (this.options.skipDays !== false && !this.options.daysToSkip) {
parser.once(‘skipdays’, (data) => {
this.options.daysToSkip = [].concat(data.day);
});
}
// Compare date when first item is encountered.
const firstitem = (item: FeedItem) => {
// If date is the same as last, abort.
if (date && this.options.lastDate === date) {
return success();
}
if (shouldSkip()) {
return success();
}
// Continue if dates differ.
if (date) {
this.options.lastDate = date;
}
parser.on(‘item’, getItem);
getItem(item);
};
parser.once(‘item’, firstitem);
const getItemDate = (item: FeedItem) => +new Date(item.pubdate as string || item.published as string || 0);
const getItem = (item: FeedItem) => {
if (sortOrder === 0) {
items.push(item);
sortOrder = getItemDate(item) – getItemDate(items[0]);
if (sortOrder < 0) {
items.forEach(getOlderItem);
} else if (sortOrder > 0) {
items.forEach(getNewerItem);
}
} else if (sortOrder < 0) {
getOlderItem(item);
} else {
getNewerItem(item);
}
};
const getOlderItem = (item: FeedItem) => {
if (this._first) {
newItems.push(item);
} else if (!ended) {
let emitted = this.news.emit(‘item’, item);
if (emitted) {
newItems.push(item);
} else {
// Check if this item has already been read in previous requests
// if it has, then stop parsing the rest of the document.
parser.removeListener(‘item’, getItem);
success();
}
}
};
let foundPrevItem = false;
const getNewerItem = (item: FeedItem) => {
if (this._first) {
newItems.push(item);
} else if (!foundPrevItem && !this.news.emit(‘item’, item)) {
foundPrevItem = true;
} else if (foundPrevItem && this.news.emit(‘item’, item)) {
newItems.push(item);
}
};
req.pipe(parser);
parser.on(‘finish’, () => {
if (ended) { return; }
// Process items in descending order if no order found at end.
if (sortOrder === 0 && newItems.length === 0) {
items.forEach(getOlderItem);
}
success();
this._first = false;
});
});
req.on(‘error’, error);
}
}
module.exports = FeedSub;
Advanced Node JS Project Ideas
14. Create a social network
A lot of more complicated project ideas will require additional frameworks like Express. In this case, you’ll probably need to use React technology along with Node.js. But a social network can be as complex or simple as you want it to be. Start with user logins and a way for users to share statuses and other media. From there, look at the ways users would interact with each other: following, liking, and sharing.
Answer this: Every social network operates a little differently. Instagram allows photos. Facebook allows anything. Twitter allows short bites. How would your social network be different? What would make it special?
Github: orca (ElevenSymbols)
15. Downtime monitoring and reporting.
A service monitoring system tells you when a system is down. It’s a very advanced function, but it’s also useful. You want to be able to tell when your services are no longer available. Use Node.js to check to see whether something is up. If it’s down, it should be able to report it to a dashboard or an email address. Consider creating a dashboard that shows multiple services and their statuses.
Answer this: What if you didn’t want to just detect whether a system is down, but whether it’s slower than average? How would you be able to tell whether the quality of the connection is bad rather than just whether the system is available at all? What kind of reporting functionality would you need to be immediately alerted to problems?
Github: watchmen (iloire)
16. An online photo collage tool
Let’s get into some media now. An online photo collage tool is a lot like an online photo editor. You upload your photos, order them how you want, and another image gets generated altogether. You will learn the basics of processing images through this Node.js project, as well as how to store images that you’ve modified online.
Answer this: What if you wanted to apply filters to photos just like you can on Instagram and other social media sites? What would you need to install, such as third-party APIs, to apply a filter in this way? What other features do you think people might want?
import Promise from ‘bluebird’;
import sizeOf from ‘image-size’;
import Canvas from ‘canvas’;
import { computeRowLayout } from ‘./layouts/justified’;
import { findIdealNodeSearch } from ‘./utils/findIdealNodeSearch’;
import { getPhoto } from ‘./utils/photo’;
function getRowLayout(photos, containerWidth, targetRowHeight = 300) {
let limitNodeSearch = 2;
if (containerWidth >= 450) {
limitNodeSearch = findIdealNodeSearch({ containerWidth, targetRowHeight });
}
const thumbs = computeRowLayout({
containerWidth,
limitNodeSearch,
targetRowHeight,
margin: 0,
photos,
});
const rows = [];
let currentRow = [];
let width = 0;
thumbs.forEach((thumb) => {
if (Math.round(width + thumb.width) > containerWidth) {
rows.push(currentRow);
currentRow = [];
width = thumb.width;
} else {
width += thumb.width;
}
currentRow.push(thumb);
});
if (currentRow.length > 0) rows.push(currentRow);
return rows;
}
function getCanvasWidth(rows) {
return rows[0].reduce((width, element) => width + element.width, 0);
}
function getCanvasHeight(rows) {
return rows.reduce((height, row) => height + row[0].height, 0);
}
function getPositions(rows) {
let y = 0;
return rows.map((row) => {
let x = 0;
const position = row.map((thumb) => {
const thumbX = x;
x += thumb.width;
return { x: thumbX, y };
});
y += row[0].height;
return position;
});
}
// eslint-disable-next-line import/prefer-default-export
export async function createCollage(sources, maxWidth, mimeType = ‘image/png’) {
const photos = await Promise.all(sources.map(getPhoto));
const sizes = await Promise.all(photos.map(sizeOf));
const photosWithSizes = photos.map((photo, index) => ({
photo,
…sizes[index],
}));
const rows = getRowLayout(photosWithSizes, maxWidth);
const canvasHeight = getCanvasHeight(rows);
const canvasWidth = getCanvasWidth(rows);
const positions = getPositions(rows);
const canvasCollage = Canvas.createCanvas(canvasWidth, canvasHeight);
const ctx = canvasCollage.getContext(‘2d’);
rows.forEach((row, i) => {
row.forEach(({ height, width, photo }, j) => {
const img = new Canvas.Image();
const { x, y } = positions[i][j];
img.src = photo;
ctx.drawImage(img, x, y, width, height);
});
});
return canvasCollage.toBuffer(mimeType);
}
17. Create a road trip planner
If you’ve recently taken classes in computer science, you know that this is more complex than it seems. Road trip planning is interesting because it requires calculating the shortest available distance between points A and B, which is something that is extremely important to be able to do for a variety of applications. A road trip just makes the question a little less abstract. Make a road trip planner that can plan out a complete trip, from one end of a region to the other.
Answer this: What if you needed to add secondary stops, such as going from Point A to Point B to Point C? What if you wanted a list of all major attractions between those areas and wanted to program your road trip planner to take those into account? What if some of your road trippers had special considerations? What if you wanted to manage the time you spent on the road?
Github: trip-planner (lance-menard)
18. Develop a daily sleep tracker
Not just great for your programming, but also great for your health! A daily sleep tracker should be able to tell you how long you’re sleeping and how well you’re sleeping. You should be able to see graphs that show trends over time, and you should be able to add notes to certain days so you know why you got less sleep or more sleep. Make beautiful charts with this sleep tracker to fully utilize JS functions.
Answer this: What if you wanted to tie this into a Fitbit or another reporting application? There are third-party APIs that provide data directly from a user’s device. Your daily sleep tracker could be more useful and usable by applying this data.
const express = require(‘express’);
const connectDB = require(‘./config/db’);
const path = require(‘path’);
const app = express();
// Connect database
connectDB();
// Init middleware
app.use(express.json({ extended: false }));
// Define routes
app.use(‘/api/users’, require(‘./routes/api/users’));
app.use(‘/api/auth’, require(‘./routes/api/auth’));
app.use(‘/api/event’, require(‘./routes/api/event’));
// Serve static assets in production
if (process.env.NODE_ENV === ‘production’) {
// Set static folder
app.use(express.static(‘frontend/build’));
app.get(‘*’, (req, res) => {
res.sendFile(path.resolve(__dirname, ‘frontend’, ‘build’, ‘index.html’));
});
}
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));
Following Up Your Node JS Project Ideas
Once you’re done building your first projects, you can build a complete Node.JS portfolio. And if you’re looking for a career in Node.js, you should follow it up with Node JS Interview Questions. Most people who are familiar with JavaScript should be able to take to Node.js quite quickly. You can also continue to learn with Express.js and other packages and libraries.
Frequently Asked Questions
Is Node.JS good for big projects?
Node.JS is best for lightweight, streamlined, sophisticated projects — regardless of their size. When creating larger projects, put special care into resource management because Node.JS is single-threaded by nature.
Is Node.JS good for beginners?
Node.JS is an intuitive development server environment that’s suited to both beginners and more advanced users. It helps if a developer has prior knowledge of JavaScript, which is the language that Node.JS supports.
How do I create a new Node.JS project?
1. Install GIT and Node.js on your computer.
2. Use NPM to initialize the project (“npm init”).
3. Open the file that has been created.
Recommended Articles
Top courses in Node.Js
Node.Js students also learn
Empower your team. Lead the industry.
Get a subscription to a library of online courses and digital learning tools for your organization with Udemy Business.