diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..322e051 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Use the official Node.js image with Alpine +FROM node:alpine + +# Create and change to the app directory +WORKDIR /usr/src/app + +# Copy package.json and package-lock.json files to the working directory +COPY package*.json ./ + +# Install the dependencies +RUN npm install + +# Copy the application source +COPY . . + +# Expose the MQTT port +EXPOSE 1883 + +# Run the MQTT broker +CMD ["node", "broker.js"] diff --git a/README.md b/README.md index e69de29..68bb9aa 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,25 @@ +npm install aedes --save +npm install aedes-cli --global + + +``` +const aedes = require('aedes')(); +const server = require('net').createServer(aedes.handle); +const port = 1883; + +server.listen(port, function () { + console.log('Aedes broker started and listening on port ', port); +}); + +aedes.on('client', function (client) { + console.log('Client Connected:', client.id); +}); + +aedes.on('clientDisconnect', function (client) { + console.log('Client Disconnected:', client.id); +}); + +aedes.on('publish', function (packet, client) { + console.log('Published:', packet.payload.toString()); +}); +``` \ No newline at end of file