在本地计算机上运行 TabNews 是一项非常简单的任务。
你需要安装两个主要依赖项:
使用?然后,可以在项目文件夹中运行以安装和使用最合适的 Node.js 版本。
nvm
nvm install
所以下载仓库后,一定要安装本地项目依赖:
npm install
要在本地运行项目,只需旋转以下命令:
npm run dev
这将自动运行数据库(包括迁移)、邮件服务器等服务,并将在以下地址公开 Web 服务(前端和 API):
http://localhost:3000/
http://localhost:3000/api/v1/status
观察:
CTRL+C
.env
在开发环境中,你可以手动创建用户(包括接收和测试激活电子邮件),也可以使用已激活的预注册用户以方便你使用。
teste@teste.com
默认情况下,运行该命令时,将注入两个激活的用户,一个具有标准功能,另一个具有管理功能,例如使用 API 运行迁移或更改其他用户内容的能力。以下是这两个用户的凭据(+):
npm run dev
"email"
"senha"
"admin@admin.com"+
"password"
"user@user.com"+
"password"
根据你要执行的操作,有几种方法可以运行测试,但是在对项目进行任何更改之前的第一步通常是运行测试,以确保一切按预期进行。以下命令将运行所有必要的服务,运行测试,然后删除所有服务。
npm test
如果要在开发时保持服务和测试运行(并在每次更改时再次运行),请使用以下命令:
npm run test:watch:services
Web 服务和 Jest(测试)日志将混合在一起,因此如果要单独运行它们,请打开两个单独的终端并旋转以下内容:
# Terminal 1
npm run dev
# Terminal 2
npm run test:watch
如果你不想在所有测试中都给出,只想隔离 1 个测试文件(或一个测试组),你可以使用一个简单的来给出你想要的,例如:
watch
regex
match
# Rodar apenas /tests/api/v1/_use-cases/registration-flow.test.js
npm run test:watch -- registration-flow
# Rodar todos os testes de "users" da api "v1"
npm run test:watch -- v1/users/
# Rodar apenas /tests/api/v1/users/[username]/patch.test.js
npm run test:watch -- username./patch
# tests/integration/api/v1/contents/[username]/[slug]/get.test.js
npm run test:watch -- contents/.username./.slug./get
观察:
/
[
regex
.
match
[
]
你可以使用该脚本,例如:
migration:create
npm run migration:create alter table users add tabcoins
这将导致:
Created migration -- ./infra/migrations/1655399502254_alter-table-users-add-tabcoins.js
如果此新迁移有效,它将在下次运行命令时自动运行。否则,服务将不会启动,错误日志将记录在项目根目录下的文件中。
npm run dev
migrations.log
完成更改并确保所有测试都通过常规命令后,就可以提交更改了。
npm test
为了帮助我们使用提交模式,请旋转以下命令并按照说明进行操作:
npm run commit