This is a Next.js project bootstrapped with create-next-app
. It provides a web interface for hashing SQL query column names. It features a SQLite database to store and manage the hashed column names, an API for hashing queries, and a front-end for user interactions. The application allows users to input SQL queries, returns queries with hashed column names, and provides the ability to view and delete entries in the database.
A weekend project. Full blog about it will follow soon!
- Node.js (minimum v18 for compatibility with latet Next.js)
- Docker and Docker Compose (for deployment)
To clone the project and get started, run the following commands:
git clone https://github.com/ahmad-alkadri/sql-hasher-app.git
cd sql-hasher-app
To install all necessary Node.js packages, simply run:
npm install
And finally, to run the application in Development mode:
npm run dev
This will start the Next.js development server, by default accessible at http://localhost:3000.
Just like typical Next.js app, the structure of the application is as follows:
pages/api
: Contains the API endpoints, including hashing logic and database interactionspages/index.js
: The main front-end component of the application.- Additional utility scripts and components as needed.
This project uses Jest
for unit testing. To run the tests:
npm test
The tests cover:
- API endpoints functionality (hashing and database interactions).
hashAllColumnRefObjects
function correctness.
More test cases will follow. You're also free to contribute to more test cases.
Currently there's only one mode of deployment, that is, using Docker Compose for local deployment.
- Build the Docker image:
docker-compose build
# For new build without cache at all:
# `docker-compose build --no-cache`
- Start the application:
docker-compose up -d # In detached mode
The two commands above will build the Docker image, run tests, and if successful, start the application. The app will be accessible at http://localhost:3000 or the respective host's IP address.
- Stop the application:
docker-compose down
- Remove docker containers completely (optional):
docker-compose down --rmi all -v