Is there any way we can create the apps as a server and client in the same time ? such as socket.io wrapper?

I want to create p2p app which only involve the ionic as the server as well as client. So for example, the socket.io is code within ionic. not outside the ionic eg. code in nodejs. the target is to create serverless p2p app within ionic.