Node.js Web应用开发的全功能样板项目
Hackathon Starter是一个功能丰富的Node.js Web应用样板项目。它集成了多种认证方式、用户管理和API示例,简化了开发流程。该项目以简单易用为核心,同时保持通用性和可重用性,适用于黑客马拉松和各类Web应用开发。其详尽文档和完备功能使开发者能快速启动项目,将精力集中在核心业务逻辑上。项目特点包括本地认证、OAuth 2.0社交登录、用户账户管理、API集成示例等。它还提供了文件上传、CSRF保护、MVC结构等实用功能。Hackathon Starter旨在为开发者提供一个全面而灵活的起点,无论是用于快速原型开发还是作为学习资源,都能满足多样化的Web应用需求。
Live Demo: Link
Jump to What's new?
A boilerplate for Node.js web applications.
If you have attended any hackathons in the past, then you know how much time it takes to get a project started: decide on what to build, pick a programming language, pick a web framework, pick a CSS framework. A while later, you might have an initial project up on GitHub, and only then can other team members start contributing. Or how about doing something as simple as Sign in with Facebook authentication? You can spend hours on it if you are not familiar with how OAuth 2.0 works.
When I started this project, my primary focus was on simplicity and ease of use. I also tried to make it as generic and reusable as possible to cover most use cases of hackathon web apps, without being too specific. In the worst case, you can use this as a learning guide for your projects, if for example you are only interested in Sign in with Google authentication and nothing else.
“Nice! That README alone is already gold!”<br> — Adrian Le Bas
“Awesome. Simply awesome.”<br> — Steven Rueter
“I'm using it for a year now and many projects, it's an awesome boilerplate and the project is well maintained!”<br> — Kevin Granger
<h4 align="center">Modern Theme</h4>“Small world with Sahat's project. We were using his hackathon starter for our hackathon this past weekend and got some prizes. Really handy repo!”<br> — Interview candidate for one of the companies I used to work with.
MongoDB (local install OR hosted)
Command Line Tools
<img src="https://upload.wikimedia.org/wikipedia/commons/1/1b/Apple_logo_grey.svg" height="17"> Mac OS X: Xcode (or OS X 10.9+: xcode-select --install
)
<img src="https://upload.wikimedia.org/wikipedia/commons/8/87/Windows_logo_-_2021.svg" height="17"> Windows: Visual Studio Code + Windows Subsystem for Linux - Ubuntu OR Visual Studio
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9e/UbuntuCoF.svg/512px-UbuntuCoF.svg.png?20120210072525" height="17"> Ubuntu / <img src="https://upload.wikimedia.org/wikipedia/commons/3/3f/Linux_Mint_logo_without_wordmark.svg" height="17"> Linux Mint: sudo apt-get install build-essential
<img src="https://upload.wikimedia.org/wikipedia/commons/3/3f/Fedora_logo.svg" height="17"> Fedora: sudo dnf groupinstall "Development Tools"
<img src="https://en.opensuse.org/images/b/be/Logo-geeko_head.png" height="17"> OpenSUSE: sudo zypper install --type pattern devel_basis
Note: If you are new to Node or Express, you may find Node.js & Express From Scratch series helpful for learning the basics of Node and Express. Alternatively, here is another great tutorial for complete beginners - Getting Started With Node.js, Express, MongoDB.
Step 1: The easiest way to get started is to clone the repository:
# Get the latest snapshot git clone https://github.com/sahat/hackathon-starter.git myproject # Change directory cd myproject # Install NPM dependencies npm install # Then simply start your app node app.js
Note: I highly recommend installing Nodemon. It watches for any changes in your node.js app and automatically restarts the server. Once installed, instead of node app.js
use nodemon app.js
. It will
save you a lot of time in the long run, because you won't need to manually restart the server each time you make a small change in code. To install, run sudo npm install -g nodemon
.
Step 2: Obtain API Keys and change configs if needed After completing step 1 and locally installing MongoDB, you should be able to access the application through a web browser and use local user accounts. However, certain functions like API integrations may not function correctly until you obtain specific keys from service providers. The keys provided in the project serve as placeholders, and you can retain them for features you are not currently utilizing. To incorporate the acquired keys into the application, you have two options:
export
command like this: export FACEBOOK_SECRET=xxxxxx
. This method is considered a better practice as it reduces the risk of accidentally including your secrets in a code repository..env.example
file: Open the .env.example
file and update the placeholder keys with the newly acquired ones. This method has the risk of accidental checking-in of your secrets to code repos.What to get and configure:
SMTP
reCAPTCHA
OAuth for social logins (Sign in with / Login with)
API keys for service providers in the API Examples if you are planning to use them.
MongoDB Atlas
Email address
ngrok and HTTPS
If you want to use some API that needs HTTPS to work (for example Pinterest or Facebook),
you will need to download ngrok. Start ngrok, set your BASE_URL to the forwarding address (i.e https://3ccb-1234-abcd.ngrok-free.app
), and use the forwarding address to access your application. If you are using a proxy like ngrok, you may get a CSRF mismatch error if you try to access the app at http://localhost:8080
instead of the https://...ngrok-free.app address.
After installing or downloading the standalone ngrok client you can start ngrok to intercept the data exchanged on port 8080 with ./ngrok http 8080
in Linux or ngrok http 8080
in Windows.
Step 3: Develop your application and customize the experience
Step 4: Optional - deploy to production See:
You will need to obtain appropriate credentials (Client ID, Client Secret, API Key, or Username & Password) for API and service provides which you need. See Step 2 in the Getting started section for more info.
Obtain SMTP credentials from a provider for transactional emails. Set the SMTP_USER, SMTP_PASSWORD, and SMTP_HOST environment variables accordingly. When picking the smtp host, keep in mind that the app is configured to use secure SMTP transmissions over port 465 out of the box. You have the flexibility to select any provider that suits your needs or take advantage of one of the following providers, each offering a free tier for your convenience.
Provider | Free Tier | Website |
---|---|---|
SendGrid | 100 emails/day for free | https://sendgrid.com |
SMTP2Go | 1000 emails/month for free | https://www.smtp2go.com |
Brevo | 300 emails/day for free | https://www.brevo.com |
.env
. These keys will be accessible under Settings, reCAPTCHA keys drop down if you need them again laterhttp://localhost:8080
, etc)http://localhost:8080/auth/google/callback
).env
http://localhost:8080/auth/snapchat/callback
).env
.env
.env
.env
localhost
under App Domainshttp://localhost:8080
, etc) under Site URLhttp://localhost:8080/auth/facebook/callback
AI辅助编程,代码自动修复
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。
AI小说写作助手,一站式润色、改写、扩写
蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。
全能AI智能助手,随时解答生活与工作的多样问题
问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。
实时语音翻译/同声传译工具
Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。
一键生成PPT和Word,让学习生活更轻松
讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。
深度推理能力全新升级,全面对标OpenAI o1
科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。
一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型
Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语 音助手开发等。
AI助力,做PPT更简单!
咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。
选题、配图、成文,一站式创作,让内容运营更高效
讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。
专业的AI公文写作平台,公文写作神器
AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。
最新AI工具、AI资讯
独家AI资源、AI项目落地
微信扫一扫关注公众号